Macro Counter Help
Moderators: dorpond, trevor, Azhrei, Gamerdude
Macro Counter Help
So I've been trying to figure out how to make a macro that keeps a record on how many times its been used. Basically I want the output to read something along the lines of: "You have __ charges left." I've looked over the macro resources and have been trying to figure it out all night but I can't seem to get it to keep track of the new value in between uses. Any help would be appreciated. Thanks
- Sol Invictus
- Cave Troll
- Posts: 95
- Joined: Fri Oct 21, 2011 12:48 pm
- Location: Jena/Thuringia/Germany
Re: Macro Counter Help
There is simple and rather primitive way to do that:
Create a property, named e.g. "Charges", and assign a value to it.
Create a macro that substracts 1 from Charges.
Then have it read out the Charges value.
The macro might look like that:
[h: Charges = Charges -1]
[r: "You used one charge and you have " + Charges + " Charges left."]
Create a property, named e.g. "Charges", and assign a value to it.
Create a macro that substracts 1 from Charges.
Then have it read out the Charges value.
The macro might look like that:
[h: Charges = Charges -1]
[r: "You used one charge and you have " + Charges + " Charges left."]
Re: Macro Counter Help
The problem with that is that I'm trying not to edit the token properties. I'm using a framework that already has extensive properties and would rather not risk messing something up for this. Also, I was hoping to have multiples of this macro but with different charge amounts such as "X" many arrows remaining, and a different macro with "Y" many +1 arrows remaining. Thanks for the reply and sorry I wasn't more clean in my OP.
Re: Macro Counter Help
Then simply use setProperty and getProperty. In that case you don't add any extra props to the framework but just to the relevant tokens. Note that that is the ONLY way of doing it. Storing on a token that is. You could also use a lib token to store the value on but my guess is that is way to much hassle.
Edit: note that when you use getProperty on a token where the property is not yet set it will return "".
Edit: note that when you use getProperty on a token where the property is not yet set it will return "".
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: Macro Counter Help
Thank you both for your help! I was able to get it working just the way I had hoped. One of the great things about maptool is all the community support available to people. Thanks again!
- CoveredInFish
- Demigod
- Posts: 3104
- Joined: Mon Jun 29, 2009 10:37 am
- Location: Germany
- Contact:
Re: Macro Counter Help
When you use get/setProperty and want it to work with an existing framework you should use prefixes on your property names that are unlikely used by another author.
Eg I use "cif.dl.propertyName" on properties in my (coveredInFish) deadlands (dl) framework. (actually i dont - i didnt saw the necessity to do so when I wrote that, but when I'd do this today I would)
Eg I use "cif.dl.propertyName" on properties in my (coveredInFish) deadlands (dl) framework. (actually i dont - i didnt saw the necessity to do so when I wrote that, but when I'd do this today I would)