#Best Way to Store Values
1 messages · Page 1 of 1 (latest)
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.
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.
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
If I set the property, won't it get overridden every time the macro is ran ? (Reset back to default)
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
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
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.
Potion usages, wand charges, different types of ammo I'm using
The counters may do it for you, but in case not you wouldn't be referencing the setup macro each time, you'd have a separate setup macro that restores all the values. Then when you want to use a resource, you'd do something like,
[var=getProperty("resource")] [var=var-1] [setProperty("resource",var)]
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
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.
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.
I tried that. It still prints and empty chat string to the chat
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.
Actually, no, sorry. i got a syntax error with option #2.
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.