Page 1 of 1

New functions (question)

Posted: Fri Aug 22, 2008 3:07 pm
by bobthedog
Okay, so I decided to try out some of the new features in b40 (specifically, the new functions to set/get a bunch of token stuff). To start, I was going to make a Saving Throw (4e) macro, that would ask you for what you're saving against, and unset the state if you save successfully. Here's the code I came up with:

Code: Select all

<!--
[Cond = Effect]
[Save = 1d20+MiscSaveBonus]
[setState(Cond, if(Save >= 10, 0, 1))]
-->
<b>Saving Throw{if(Cond == "0", "", " vs. "+Cond)}: {Save}</b>
This code doesn't work. Well, it does, but the line that should unset the state just gives "invalid expression".

So I thought "hmm, maybe it doesn't work well with if clauses", and shifted stuff around. Still nothing. Then I tried changing caps all around the function.

Then I tried all the other functions listed in the announcement thread. None are working.

Any ideas?

Edit: stupid HTML

Posted: Mon Aug 25, 2008 3:36 pm
by bobthedog
*bump*

So, no one else running into problems with the new functions?

Posted: Mon Aug 25, 2008 3:51 pm
by knizia.fan
I don't seem able to make getState() and setState() work. However, the alternative syntax using state.Dead, state.Disabled, etc. does work, so you can get and set the states that way.

Other new functions like getTokenImage() and getStateImage() are working for me.

Posted: Mon Aug 25, 2008 3:53 pm
by Naryt
I can't help as I'm not running b40 (fearful of the campaign munching it's been reported to do).

Posted: Mon Aug 25, 2008 4:08 pm
by bobthedog
knizia.fan wrote:I don't seem able to make getState() and setState() work. However, the alternative syntax using state.Dead, state.Disabled, etc. does work, so you can get and set the states that way.

Other new functions like getTokenImage() and getStateImage() are working for me.
Yea, the "old" way still works (like state.Blah). My problem is assigning the state dynamically as part of the macro.

Like my example macro above: it prompts the user for a Condition. Then it rolls a save, and if the save succeeds, it toggles the equivalent state off.

So if there is a token state called Poison, and the macro rolls a save vs. poison, you don't need to unset the Poison state manually. Nor do you need one macro for each different token state.

Posted: Mon Aug 25, 2008 4:13 pm
by knizia.fan
Until those functions start working, you can work around this with the eval function.

[eval("token." + stateName + "= 1")]

should work.

You said none of the new functions were working for you. Does that include getTokenImage() and getStateImage()? Those two work for me.

Posted: Mon Aug 25, 2008 4:21 pm
by bobthedog
knizia.fan wrote:Until those functions start working, you can work around this with the eval function.

[eval("token." + stateName + "= 1")]

should work.

You said none of the new functions were working for you. Does that include getTokenImage() and getStateImage()? Those two work for me.
No time to test those two specific ones, but I did try getName() and setName() and some other ones. Once the 5th or 6th didn't work, I assumed none of them were working, since they're all the same "bundle".

Also, thanks for the workaround suggestion, when I have the time I'll test that. Oh, and it should read

[eval("state." +......

shouldn't it?

Posted: Mon Aug 25, 2008 10:41 pm
by Craig
Ok my fault my brain went MIA while typing patch notes to send to Trevor :oops:

The functions that work are
tblImage()
getGMName()/setGMName()
getHalo()/setHalo()
getTokenImage()
getStateImage()

I accidentally put an extra "Token" in some in the notes (getTokenGMName())

As for getState()/setState() I don't have any idea what happened with that one but you can probably blame me too :)

I have sent a patch to fix get/setState() to Trevor, but given he is probably currently building release 41 it may not make it into that.