#Best Way to Store Values

1 messages · Page 1 of 1 (latest)

honest thunder
#

What's the best way to store variables that can be accessed (for read and write) from other macros? An example would be a starting # of potions, with the ability for another macro to reduce or increase the counter dynamically.
I am not the GM so don't have access to 'edit campaign properties' to create new properties.

hard kernel
#

You can use setProperty() - sounds like this is a variable just used by one token? Not being the GM shouldn't be an issue in this case, you can set properties that aren't in the campaign properties list. They just won't appear in the Edit Token dialog.

https://wiki.rptools.info/index.php/setProperty

honest thunder
#

Yes, just a single token uses it. I can use a form (or input fields) ahead of the campaign start to set the values. That'll work, thanks.

fading sedge
#

I like to use the Speech Tab for those cases. It's essentially the same as props except you can see and edit them if required

honest thunder
#

If I set the property, won't it get overridden every time the macro is ran ? (Reset back to default)

hard kernel
#

Depends how you set it up. I have one macro that resets all the values (e.g. a long rest macro) and the rest all use whatever resource

honest thunder
#

So is it possible to just make a setup macro that sets and stores the initial values, then have other macros just access that macro without actually running it again, just to get and set values ?

#

I kind of like metas idea of using speech text

tropic beacon
#

Are you using this entirely for counters like potion numbers? If so there are some simple lib tokens that might help.

In [custom counters] (https://github.com/melek/CustomCounters) I use a JSON object set on the 'customCounters' property to keep all the counters in one predictable place.

honest thunder
#

Potion usages, wand charges, different types of ammo I'm using

hard kernel
honest thunder
#

Yeah that's what I figured

#

I considered building a plugin to display all the stuff in a table in a frame that snaps to the window and automatically updates whenever I use something

#

But want to start simple first

honest thunder
#

Hmm, is there a way to leave comments in a macro? Just using <!-- --> sends an empty string to the chat. Trying to leave myself some notes for later in my macro as I am not done with it yet, but don't want it to print an empty string whenever I use my macro.

tropic beacon
#

No formal comment notation in MT script. You can just put a string in a hidden roll: [h: "Comment here!"]

I usually make it an HTML comment as well, just so it's really obvious it's a comment when scanning:

[h: "<!-- Comment! -->"]

It's a bit verbose but I like it.

honest thunder
#

I tried that. It still prints and empty chat string to the chat

topaz quartz
#

It shouldn't. You probably have something else going to chat that can't be seen. You could save and view your chat log and it will show the html being sent.

honest thunder
#

Actually, no, sorry. i got a syntax error with option #2.

topaz quartz
#

Afaik, I was the first to suggest using the statement comment which works fine for single button executable macros, but I prefer using User Defined Functions (UDFs) and turning the output off. see defineFunction() Then your clickable macros look like this [H: myFunction()]
and your function can have all the html comments without the special formatting you want.

#

Any output from those macros can use broadcast(), but I have a special function called chat() that uses broadcast and mimics normal chat format.