Just started doing some Macro writing( slowly learning) so don't know all the terms yet but having trouble with calling macros and returning info
I have an Inventory button on a player PC (TUKKI) token which opens a dialog with macro links to all items they have on a library token Lib:INVENTORY.
He chooses Ring of the Ram
The Ring of the Ram macro on the lib token displays a frame with the info about the ring and also a further option to the USE CHARGE global macro which needs to know the CHARGES property from the TUKKI token to run
When operated from the TUKKI player token it asks for values for CHARGES
i know that this is because the USE CHARGE macro now thinks the Library token is the current token I just don't know how to fix it.
I have looked at the documentation for switch token etc but cannot make it work without having to put the pc token name each time and I want it to run for all players
I know there is a way to do this.
Also, is there a way you can have an input that asks for a name and then runs like this
INPUT = Magic Missile
It then runs a macro called
Magic Missile @Lib:Spells
ie it automatically inserts the input into the macro command
Thank you to anyone who spends time to respond. This macro writing lark is fun.
Getting property from non selected token
Moderators: dorpond, trevor, Azhrei
Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior.
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior.
Re: Getting property from non selected token
When it asks for a variable it just means that variable isn't currently defined. The macro should ask for charges, write that value to the current token (not lib token) then everything should be fine. Well, that's the way it should be.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Getting property from non selected token
so you start from the player token, meaning that its 'known'. when the player runs the macro and the frame is opened just make sure the token name (or better: id) is passed along to the frame and when the frame is 'done' the same value is passed onto 'charge' macro. Its a bit of a hassle to keep track of it, but not undoable.
When you finally arrive at 'charge' macro just run switchtoken(whateverispassedon) and then the rest
When you finally arrive at 'charge' macro just run switchtoken(whateverispassedon) and then the rest
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: Getting property from non selected token
Thanks for reply.
Make sure the token name (or better: id) is passed along to the frame and when the frame is 'done' the same value is passed onto 'charge' macro
Trouble is I don't know how to do this. Could you write an example of the code if possible
PLAYER TOKEN = TUKKI
Macro on TUKKI token = INVENTORY containing macro link to.."Ring of the ram" macro on...
Library token = Lib:INVENTORY
ring of the ram macro on lib token contains link to USE CHARGE global macro
USE CHARGE macro changes CHARGES property on TUKKI
I tend to learn best when I have an example and can then sort of backward engineer it
Thanks
Make sure the token name (or better: id) is passed along to the frame and when the frame is 'done' the same value is passed onto 'charge' macro
Trouble is I don't know how to do this. Could you write an example of the code if possible
PLAYER TOKEN = TUKKI
Macro on TUKKI token = INVENTORY containing macro link to.."Ring of the ram" macro on...
Library token = Lib:INVENTORY
ring of the ram macro on lib token contains link to USE CHARGE global macro
USE CHARGE macro changes CHARGES property on TUKKI
I tend to learn best when I have an example and can then sort of backward engineer it
Thanks
Re: Getting property from non selected token
something like:
or maybe
should work.
ring of ram then should start with:
[token = arg(0)]
the other stuff is arg(1), arg(2) etc.
Code: Select all
[macro("ring of ram@lib:inventory"):token.name]
Code: Select all
[macro("ring of ram@lib:inventory"):json.append("",token.name, other, stuff, you, want, to, pass, on)]
ring of ram then should start with:
[token = arg(0)]
the other stuff is arg(1), arg(2) etc.
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: Getting property from non selected token
Thanks for your reply but sadly I cannot get it to work.
The USECHARGE global macro still asks for CHARGES value.
I fear I am just not advanced enough to understand where it is going wrong. Something to fix in the future.
Is the second part of my original question possible?
The USECHARGE global macro still asks for CHARGES value.
I fear I am just not advanced enough to understand where it is going wrong. Something to fix in the future.
Is the second part of my original question possible?
Re: Getting property from non selected token
can you post teh macro that you have?
a wild guess is that you're not using Wiki: getProperty()
a wild guess is that you're not using Wiki: getProperty()
NPUT = Magic Missile
It then runs a macro called
Magic Missile @Lib:Spells
ie it automatically inserts the input into the macro command
Code: Select all
[abort(input(
"macroName||Give name of macro",
"importantValue||Give important value"
))]
[macro(macroName+"@lib:Spells"):importantValue]
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: Getting property from non selected token
Thank you for the Input macro name info. That works nicely.
As to my original issue.....
Ring macro on TUKKI pc token =
[frame("
Ring of the Ram
"):{
<img src='[r:tblImage("MAGIC ITEMS",20)]'><span style="color:blue">
<br><br>
<i> This magical ring has a rams head shaped gem</i><br><br>
Regains 1d3 charges at dawn
<br>
</span>
<span style="background-color:aqua"><b><i><font size=5> [r: macroLink(" Use Charge", "USECHARGE2@GM", "gm-self", "count=6", "impersonated")]<br></span>
</p></body></html>}]
USECHARGE2 Macro on GM=
[h:CHARGES=CHARGES-1]
[if(CHARGES<=0),code:{
[H:CHARGES=0]
};{}]
I tried the switch token function but it said I did not have permission
I tried the get Property function but could not get it to return to the Tukki token to change the properties CHARGES.
Thanks again
As to my original issue.....
Ring macro on TUKKI pc token =
[frame("
Ring of the Ram
"):{
<img src='[r:tblImage("MAGIC ITEMS",20)]'><span style="color:blue">
<br><br>
<i> This magical ring has a rams head shaped gem</i><br><br>
Regains 1d3 charges at dawn
<br>
</span>
<span style="background-color:aqua"><b><i><font size=5> [r: macroLink(" Use Charge", "USECHARGE2@GM", "gm-self", "count=6", "impersonated")]<br></span>
</p></body></html>}]
USECHARGE2 Macro on GM=
[h:CHARGES=CHARGES-1]
[if(CHARGES<=0),code:{
[H:CHARGES=0]
};{}]
I tried the switch token function but it said I did not have permission
I tried the get Property function but could not get it to return to the Tukki token to change the properties CHARGES.
Thanks again