Macro Counter Help

If you have searched the other User Creations subforums and an answer to your question has not been found, please post here!

Moderators: dorpond, trevor, Azhrei, Gamerdude

Post Reply
Dead_Jim
Cave Troll
Posts: 25
Joined: Sun Mar 25, 2012 12:05 am

Macro Counter Help

Post 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

User avatar
Sol Invictus
Cave Troll
Posts: 95
Joined: Fri Oct 21, 2011 12:48 pm
Location: Jena/Thuringia/Germany

Re: Macro Counter Help

Post 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."]

Dead_Jim
Cave Troll
Posts: 25
Joined: Sun Mar 25, 2012 12:05 am

Re: Macro Counter Help

Post 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.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Macro Counter Help

Post 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 "".

Dead_Jim
Cave Troll
Posts: 25
Joined: Sun Mar 25, 2012 12:05 am

Re: Macro Counter Help

Post 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!

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: Macro Counter Help

Post 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)

Post Reply

Return to “Requests for HELLLLP!”