Can't get math to work in properties

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
perm
Kobold
Posts: 1
Joined: Sun May 15, 2016 10:13 pm

Can't get math to work in properties

Post by perm »

I am having trouble getting any math to work in my token properties.

I just want to have the MaxHP to be 10 + Constitution, because Dungeon World but it's not quite doing that...

Image

and this is what I get...

Image

That what item was me testing to see if any math works at all (it doesn't).

What am I doing wrong?


User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Can't get math to work in properties

Post by aliasmask »

If you want to have your math evaluated you need to surround with {} or preferably [r:].


User avatar
Venatius
Dragon
Posts: 256
Joined: Mon Feb 16, 2009 7:12 pm

Re: Can't get math to work in properties

Post by Venatius »

I think I see the misunderstanding afoot here, unless I've misunderstood what you're going for. See, the only thing you'll see in the Properties window is the "formula" you've put for calculating MaxHP, not the final result. It won't replace the formula with the final total - which is good, because if it just plugged in a fixed number, it wouldn't change if you later changed Constitution! Anywhere else in the code where you refer to MaxHP will correctly parse the formula, and use the final total. For instance, if I just typed (with the example token as the current token, such as by impersonating it) [r: MaxHP], it would return "24". Likewise, if MaxHP is set as being visible on the statsheet, it'll display 24, not {Constitution +10}, when you mouse over the token. So you're probably just fine as-is!

That said, I've heard it suggested before that using formulae in properties themselves should be avoided for performance (especially ones that show up on statsheets since those are refreshed every single time the token is moused over). It might be better to just have it set so that any time you perform a function that changes your Constitution, it updates your MaxHP property to Constitution+10. This is just a "best practices" thing though. While I've been trying to be a little more (huge airquotes) "professional" in my own code about this sort of thing, if just having it as a formula in the property isn't afflicting you with any major lag issues, which it probably won't if your framework isn't huge, then you're probably fine.

Post Reply

Return to “Macros”