Refferencing the same set of variables across multiple macros

Developer discussion regarding MapTool 1.4

Moderators: dorpond, trevor, Azhrei

Forum rules
Posting now open to all registered forum users.
Post Reply
SimpleQuestions
Kobold
Posts: 2
Joined: Sat Jan 09, 2021 10:07 pm

Refferencing the same set of variables across multiple macros

Post by SimpleQuestions »

Hello all! New to the Forums, thought I'd try and ask here for some code help. My issue likely just stems from not knowing the exact terminology to look up what I'm trying to do on the user guides.

I've got multiple macro buttons set up that all use the same set of variables. Here's an example of one of them;
[H: Bab=15] [H: Str=7][H: Stone=1] [H: Enh=1] [H:Pow=-4] [H:Rage=3] [H:Stance=4] [H:Pher=2] [H:Flank=2] [H:Second=-5] [H:Third=-10] [H:Knock=9] [H: Cha=-2][H: Str2=10] [H:Pow2=12]
(P.A)<br>
Earth Breaker:
[attack = 1d20+Bab+Str+Stone+Enh+Pow]
[if(attack >= (Bab+Str+Stone+Enh+Pow+20)): output = "Crit threat!,"]
[if(attack == (Bab+Str+Stone+Enh+Pow+1)): output = "MISS"]
[H: threat=if(attack>=(Bab+Str+Stone+Enh+Pow+20),1,0)]
[if(threat==1), CODE:
{[confirm = (1d20+Bab+Str+Stone+Enh+Pow)] to confirm};{}]
<br>
&nbsp &nbsp &nbsp Damage: [dmg = 2d6+Str2+Enh+Pow2]
Now, I've got something like 20 macro buttons that all use those same variables ([H: Bab=15] [H: Str=7], etc). When I need to update them, it's a pain to edit every macro. There's got to be a way to have the macro's all reference those values stored somewhere where I only have to update them in 1 place to affect all macros that call on them, but as I said before I just don't know how to phrase that while searching the guides, so I'm coming up empty.

If someone could give me some guidance on what I'm trying to do, I'd be thrilled!

User avatar
aliasmask
Deity
Posts: 8692
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Refferencing the same set of variables across multiple macros

Post by aliasmask »

Typically, you have the properties saved on a token and the macro calculates whatever it does with those properties.

SimpleQuestions
Kobold
Posts: 2
Joined: Sat Jan 09, 2021 10:07 pm

Re: Refferencing the same set of variables across multiple macros

Post by SimpleQuestions »

The game I'm in isn't using stats input into maptools for tokens and such, so don't think that solution will be able to work. Can they be set up in one macro, and then other macros reference that macro to retrieve the values?

User avatar
aliasmask
Deity
Posts: 8692
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Refferencing the same set of variables across multiple macros

Post by aliasmask »

Well, if you're going to do it the hard way, then that's what you're left with.

User avatar
bubblobill
Giant
Posts: 154
Joined: Sun Jan 24, 2010 3:07 pm

Re: Refferencing the same set of variables across multiple macros

Post by bubblobill »

I do something like this

Code: Select all

[h: defaults=getProperty("macDefaultsJson")]
[h: json.toVars(defaults)]
where "macDefaultsJson" looks like;

Code: Select all

{
"Bab":15,
"Str":7,
"Stone":1;
"Enh":1,
"Pow":-4,
"Rage":3
}
Then write another macro for editing/setting the JSON values.
Bubblobill on the forum.
@Reverend on the MapTool Discord Server

Responsible for less atrocities than most... I do accept responsibility for these though: SmartDoors, Simple d20 Framework - barebones, Drop-in: All 3.5 SRD Monsters, Drop in: Simple Character Editor, Battletech Framework

Post Reply

Return to “MapTool 1.4”