Hello! I have a problem with a macro, its an attack macro that uses properties from a selected token, it calls a function in a library token I have set up to make all the rolls and calculate damage. My problem is that it works perfectly if I use it from the Global or campaign windows, but when I try to use it from the selected window it shows an error. I know I could make my players use the macro from other window, or just use it myself, but both my players and myself are new to maptools and I would like for them to have it easy so that they cant use the macros in other tokens, and I know rolling your attack is part of the thrill of playing. When I use it from the selected window it gives me an error saying that I have no permission to access another token in the function "getProperty". Here is the code for the macro, but I'm not sure if it is a coding problem:
[h: weapon = EquippedWeapon]
[h: attacker = getName()]
[h: target = selectToken()]
[h: originalLP = getProperty("LPCurrent", target)]
[h: criticalThreshold = originalLP / 2]
[r: attackFunction(weapon, target, attacker, 0)]
[h: DamageTaken = originalLP - getProperty("LPCurrent", target)]
[r: if(DamageTaken > criticalThreshold,
add("<p style='background-color: red;'>Critical!!! ", "</p>"),
"" )]
[h: setState("Acted", 1)]
I don't think there is a problem with the function from the library token, but it doesnt even get to that part when I use it from the selected window so I'm not completely sure.
I'm sorry if this isnt supposed to be posted here, please let me know if I should change it.
Hope you al have a nice day!!
Problem with a macro in Selected Window
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
Re: Problem with a macro in Selected Window
try unchecking 'allow players to edt macro' in the macro editor (next tab)
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