I don't get macros at all apparently

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
henrygrieve
Kobold
Posts: 1
Joined: Fri Feb 07, 2025 3:50 am

I don't get macros at all apparently

Post by henrygrieve »

Hello, this is my macro

<!--

[ShieldState=ShieldApplied]

[if(ShieldState==1):ShieldApplied=0 --> Shields up,<!--]

[if(ShieldState==0): ShieldApplied=1 --> Shields down,<!--]

[if(ShieldState==1): AC = AC - ShieldBonus]

[if(ShieldState==0): AC = AC + ShieldBonus]

-->

current AC is {AC}

ShieldApplied, AC and ShieldBonus are token properties and this is a token stored macro

Trying to run this macro results in Function '-' requires at least 1 parameters; 0 were provided. error. The problem apparently is in the second condition if I misspell ShieldApplied in there it parses completely fine just doesn't work as intended

User avatar
metatheurgist
Dragon
Posts: 368
Joined: Mon Oct 26, 2009 5:51 am

Re: I don't get macros at all apparently

Post by metatheurgist »

While you can use html comment tags to hide output, this is bad practice. The macro will still output 'nothing' if you're trying to hide all output which will lead to weird things like macros spamming the chatbox with empty lines.

If you want to hide output use the [h:] roll modifier. What you're doing doesn't work because you can't just imbed those tags into MTscript.

[h:ShieldState=ShieldApplied]

[r,if(ShieldState==1): ShieldApplied=0; "Shields up"]

[r,if(ShieldState==0): ShieldApplied=1; "Shields down"]

[h,if(ShieldState==1): AC = AC - ShieldBonus]

[h,if(ShieldState==0): AC = AC + ShieldBonus]

UNTESTED!

Also, directly manipulating properties is a path to weird, hard to find bugs.

User avatar
aliasmask
RPTools Team
Posts: 9132
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: I don't get macros at all apparently

Post by aliasmask »

You need to separate your base AC from modded AC otherwise it's possible to mod the modded value. Also, the wording and logic seems to be contrary.. when shields is up, the value goes down. May want to reverse that logic. I would probably have something like this. Remove the flag and just toggle the existing state, generate message and AC and output.

Code: Select all

<!-- toggle shield state -->
[H: shieldState = 1 - shieldState]
[H: message = listGet("--> Shields Down -->,--> Shields Up <--",shieldState)]
[H, if(shieldState): AC = AC + ShieldBonus; AC = AC - ShieldBonus]

[R: strformat("%{message}<br>Current AC is %{AC}")]

Post Reply

Return to “Macros”