Page 1 of 1

Macro Counter Help

Posted: Fri Aug 03, 2012 7:01 am
by Dead_Jim
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

Re: Macro Counter Help

Posted: Fri Aug 03, 2012 7:54 am
by Sol Invictus
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."]

Re: Macro Counter Help

Posted: Fri Aug 03, 2012 2:53 pm
by Dead_Jim
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

Posted: Fri Aug 03, 2012 3:39 pm
by wolph42
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 "".

Re: Macro Counter Help

Posted: Fri Aug 03, 2012 4:44 pm
by Dead_Jim
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!

Re: Macro Counter Help

Posted: Fri Aug 03, 2012 4:47 pm
by CoveredInFish
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)