How to make a macro execute another macro?
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.
How to make a macro execute another macro?
How can I make a macro execute another macro in the same group?
Re: How to make a macro execute another macro?
See [macro:]
lib:token is the name of a token that has "lib:" in front of the name. For example, "lib:combat" would be a valid lib token name. Lib tokens hold a collection of macros that can be called by other macros but using it's name after the @ symbol. macroName is just the name you give the macro. For example, I may have "Attack" as a macro name on "lib:combat" and if want to call it I use "Attack@lib:combat".
Code: Select all
<!-- call another macro, no parameters -->
[macro("macroName@lib:token"): ""]
<!-- call another macro, give parameters -->
[macro("macroName@lib:token"): json.append("","arg1","arg2")]
<!-- get return value after calling macro -->
[H: returnVal = macro.return]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: How to make a macro execute another macro?
What if I want to call a none lib token? So say a PC token with the name "Uvogin"?aliasmask wrote:See [macro:]
lib:token is the name of a token that has "lib:" in front of the name. For example, "lib:combat" would be a valid lib token name. Lib tokens hold a collection of macros that can be called by other macros but using it's name after the @ symbol. macroName is just the name you give the macro. For example, I may have "Attack" as a macro name on "lib:combat" and if want to call it I use "Attack@lib:combat".Code: Select all
<!-- call another macro, no parameters --> [macro("macroName@lib:token"): ""] <!-- call another macro, give parameters --> [macro("macroName@lib:token"): json.append("","arg1","arg2")] <!-- get return value after calling macro --> [H: returnVal = macro.return]
EDIT: Also, once the macro from my campaign tab calls a macro from a lib token, how do I make the "lib token called macro" apply it's affects to the selected token (which I selected before clicking the macron in my campaign tab)?
- bubblobill
- Giant
- Posts: 167
- Joined: Sun Jan 24, 2010 3:07 pm
Re: How to make a macro execute another macro?
EDIT: I take it all back. Listen to him instead
Last edited by bubblobill on Tue Jul 29, 2014 7:07 am, edited 1 time in total.
Bubblobill on the forum.
@Reverend on the MapTool Discord Server
Responsible for less atrocities than most... I do accept responsibility for these though: SmartDoors, Simple d20 Framework - barebones, Drop-in: All 3.5 SRD Monsters, Drop in: Simple Character Editor, Battletech Framework
@Reverend on the MapTool Discord Server
Responsible for less atrocities than most... I do accept responsibility for these though: SmartDoors, Simple d20 Framework - barebones, Drop-in: All 3.5 SRD Monsters, Drop in: Simple Character Editor, Battletech Framework
Re: How to make a macro execute another macro?
erm...no! Generally it won'tbubblobill wrote:Generally a macro will effect the selected token properties no matter where it is called from.
It will only effect selected token IF 'apply to selected tokens' is checked (but that won't work with [macro:]) or if the macro is run from the token.
In all other cases you need to do add the following inside your macro:
Code: Select all
[tok = getSelectedNames()]
[assert(listCount(tok)==1, "make sure only one token is selected",0)]
[switchToken(tok]
<!-- your macro here -->
By using the code above in the local macro.EDIT: Also, once the macro from my campaign tab calls a macro from a lib token, how do I make the "lib token called macro" apply it's affects to the selected token (which I selected before clicking the macron in my campaign tab)?
that WON'T work (the error will tell you that only lib: tokens can be called macros from). The only way to get that working is having 'apply to selected token checked' on the campaign macro, campaign macro looks like this:...@Uvogin might work
Code: Select all
[macro("test@TOKEN"):""]
Then select the Uvogin token and then run the macro. In this case the macro is run FROM uvogin so the 'getSelectedNames' code here above is NOT required.
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: How to make a macro execute another macro?
Thanks guys; though I got another question...
Ok; let's say I select a token, and I press a macro in the campaign tab which calls a macro in a lib token. Now; when this happens, the macro from the lib token asks me for the variable values, but how do I make it use the variable values from the selected token? Without using the "apply to selected tokens" option?
Ok; let's say I select a token, and I press a macro in the campaign tab which calls a macro in a lib token. Now; when this happens, the macro from the lib token asks me for the variable values, but how do I make it use the variable values from the selected token? Without using the "apply to selected tokens" option?
Re: How to make a macro execute another macro?
Use Wiki: getSelected() to get the id and then Wiki: switchToken() to set the current impersonated token.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: How to make a macro execute another macro?
...As i already explained in my post....
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: How to make a macro execute another macro?
I have some problem with Macro arguments that i am not able to figure out...
I have a lib token named lib:AuraD
It own 3 macros
- RedTurn
- SelTarget
- CalDamage
On "Global" tab i have a macro that should call all of the macro from the lib:AuraD
Problem is that I get this error:
Statement options (if any): macro("RedTurn@lib:AuraD")
Statement Body : ""
if I try to change "" to something else i keep getting this error... I wonder when I will figure out how calling macro works on MapTool... I feel stupid...
I have a lib token named lib:AuraD
It own 3 macros
- RedTurn
- SelTarget
- CalDamage
On "Global" tab i have a macro that should call all of the macro from the lib:AuraD
Code: Select all
[macro("RedTurn@lib:AuraD"): ""]
[macro("SelTarget@lib:AuraD"): ""]
[macro("CalDamage@lib:AuraD"): ""]
Statement options (if any): macro("RedTurn@lib:AuraD")
Statement Body : ""
if I try to change "" to something else i keep getting this error... I wonder when I will figure out how calling macro works on MapTool... I feel stupid...
Re: How to make a macro execute another macro?
I dont see anything wrong with what you provided, thus the problem lies elsewhere.
E.g. names the macro differently on the lib: or a syntax error in the macro, etc.
E.g. names the macro differently on the lib: or a syntax error in the macro, 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: How to make a macro execute another macro?
I tried to change name of the macros to:
- Next
- Target
- Calcola
Macro on Global tab is:
Here is how it should work.
I have a token that represent an Area Spell that make Damage over time and lasts 10 round.
First macro should lower round count one by one.
Second one should select all the token in the Area of Effect and then deselect the friendly target.
Third one should compere atk stats with defensive stats and, if atk is successful, calculate damage.
I hope everything is clear. English is not my first language and sometimes it's hard to explain things
Obviously I keep getting the error
Edit: I tried to copy macros on the global panel to launch them directly one by one... if i do it this way everything work fine... it stop working only if i try to start them from the Lib:Token.
Last Edit... I tried to change Lib:token name... and now seems to work... As long as I would like to learn... is there a reason for this? so i can avoid to make the same error next time...
- Next
- Target
- Calcola
Macro on Global tab is:
Code: Select all
[macro("Next@lib:AuraD"): ""]
[macro("Target@lib:AuraD"): ""]
[macro("Calcola@lib:AuraD"): ""]
Spoiler
Macro "Next"
Macro "Target"
Macro "Calcola"
Code: Select all
[h: turnrim=getProperty("turni")]
[h: sott=1]
[h: calcolo=(turnrim-sott)]
[h: setProperty("turni",calcolo)]
Rimarrò attiva per altri [r: turni] turni
[h, if (calcolo>0), CODE: {
[setVisible(1)]
[setState("Hidden",0)]
};
{ [setVisible(0)]
[setState("Hidden",1)]
}]
Code: Select all
[h: penetrazione=getProperty("PenSpi")]
[h: danni=getProperty("Dan")]
[H: "Tokens = "+ listCount(getTokens())]
[H: ts = json.get(getInfo("server"),"timeInMs")]
[H: x = getTokenX()]
[H: y = getTokenY()]
[H: range = 9]
[H: gridSize = json.get(json.get(getInfo("map"),"grid"),"size")]
[H: quad1 = getTokens("json",json.set("{}","selected",0,"range",json.set("{}","upto",range)))]
[H: moveToken(x-gridSize,y)]
[H: quad2 = getTokens("json",json.set("{}","selected",0,"range",json.set("{}","upto",range)))]
[H: moveToken(x-gridSize,y-gridSize)]
[H: quad3 = getTokens("json",json.set("{}","selected",0,"range",json.set("{}","upto",range)))]
[H: moveToken(x,y-gridSize)]
[H: quad4 = getTokens("json",json.set("{}","selected",0,"range",json.set("{}","upto",range)))]
[H: moveToken(x,y)]
[H: inArea = json.intersection(json.intersection(json.intersection(quad1,quad2),quad3),quad4)]
[H: onWall = "[]"]
[H, foreach(token,inArea), code: {
[H, if(getDistance(token) == range): onWall = json.append(onWall,token)]
}]
[H: moveToken(x-gridSize,y)]
[H, foreach(token,inArea), code: {
[H, if(getDistance(token) == range): onWall = json.append(onWall,token)]
}]
[H: moveToken(x-gridSize,y-gridSize)]
[H, foreach(token,inArea), code: {
[H, if(getDistance(token) == range): onWall = json.append(onWall,token)]
}]
[H: moveToken(x,y-gridSize)]
[H, foreach(token,inArea), code: {
[H, if(getDistance(token) == range): onWall = json.append(onWall,token)]
}]
[H: moveToken(x,y)]
[H: onWall = json.unique(onWall)]
[H: time = json.get(getInfo("server"),"timeInMs") - ts]
[h: strformat("Range from token %s = %{range}",getName())]
[h: "Nell'area = "]
[h, foreach(token,inArea): getName(token)]
[h, foreach(token,inArea): selectTokens(token,1)]
[h, foreach(token,onWall): getName(token)]
[h: switchToken("AuraTemp")]
[h: setProperty("PenSpi", penetrazione)]
[h: setProperty("Dan", danni)]
[h: ids = getWithState("Amico")]
[h, foreach(id, ids), Code:{
[deselectTokens(id)]
}]
[h: ids = getWithState("Morto")]
[h, foreach(id, ids), Code:{
[deselectTokens(id)]
}]
Code: Select all
[h: switchToken("AuraTemp")]
[h:pen=getProperty("PenSpi")]
[h:danno=getProperty("Dan")]
[h: ids = getSelected()]
[h, foreach(id, ids, "<br>"),Code:{
[h: switchToken(id)]
[H: donkey=getProperty("AssFisFigura")]
[h, if(pen>=donkey), Code:{
[h:PuntiSalute = PuntiSalute - danno]
[h:bar.Health = PuntiSalute / MaxPS]
}]
[h, if(PuntiSalute <=Vit && PuntiSalute > 0): setState("Moribondo", 1); setState("Moribondo", 0)]
[h, if(PuntiSalute <=Vit && PuntiSalute > 0): text = "Atento!!! Sei in stato Moribondo. Da adesso in poi perderai 5 Punti salute alla fine di ogni tuo turno."; text=""]
[h, if(PuntiSalute <= 0): text = "Mi dispiace, sei morto!"]
[h, if(PuntiSalute <= 0): setState("Morto", 1); setState("Morto", 0)]
}]
I have a token that represent an Area Spell that make Damage over time and lasts 10 round.
First macro should lower round count one by one.
Second one should select all the token in the Area of Effect and then deselect the friendly target.
Third one should compere atk stats with defensive stats and, if atk is successful, calculate damage.
I hope everything is clear. English is not my first language and sometimes it's hard to explain things
Obviously I keep getting the error
Edit: I tried to copy macros on the global panel to launch them directly one by one... if i do it this way everything work fine... it stop working only if i try to start them from the Lib:Token.
Last Edit... I tried to change Lib:token name... and now seems to work... As long as I would like to learn... is there a reason for this? so i can avoid to make the same error next time...
Re: How to make a macro execute another macro?
what was the name of the lib token and to what name did you change it?
i also noticed : [h: turnrim=getProperty("turni")] without any context (e.g. switchtoken() or adding the id of the token where youre getting the property ffrom. That also might cause an issue.
i also noticed : [h: turnrim=getProperty("turni")] without any context (e.g. switchtoken() or adding the id of the token where youre getting the property ffrom. That also might cause an issue.
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: How to make a macro execute another macro?
The name was Lib:AuraD and I changed to lib:aura
Ok... now i am confused... I had changed nothing more... it was working... it doesn't work anymore...
I see... actually that macro have "Apply to selected token" on... it take Property from the selected token.i also noticed : [h: turnrim=getProperty("turni")] without any context (e.g. switchtoken() or adding the id of the token where youre getting the property ffrom. That also might cause an issue.
Ok... now i am confused... I had changed nothing more... it was working... it doesn't work anymore...
Re: How to make a macro execute another macro?
can you provide the campaign file here? and an explanation of how to emulate the issue.
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: How to make a macro execute another macro?
Do you want me to translate it so it comes in english? it's in Italian At the moment...
The file is almost 40MB... can i link it from dropbox or google drive?
The file is almost 40MB... can i link it from dropbox or google drive?