Displaying Current Token States on Property Sheet

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
raineym
Kobold
Posts: 1
Joined: Tue Jun 10, 2014 4:43 pm

Displaying Current Token States on Property Sheet

Post by raineym »

I'm trying to show a token's current States on the token's property sheet when you hover over it.

I've tried something similar to the below code but it just causes MapTool to go crazy and I have to force close it. (I know the code is incomplete.)

Code: Select all

[h:statesList=getTokenStates()][h:foreach(state,statesList):if(getState(state)):true_body]
I am new to MapTool scripting and any help would be appreciated.

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: Displaying Current Token States on Property Sheet

Post by CoveredInFish »

You should check code that is supposed to run on the stat sheet as macro first. Any bug in that code will cause MT to go crazy.

In the line you posted is for example wrong syntax. You combine roll options like [if:] with a comma , instead of another colon :

You could also use Wiki: if()-function but be sure to read on the differences between that and the if-roll option.

Code: Select all

[h:foreach(state,statesList), if(getState(state)):true_body]

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Displaying Current Token States on Property Sheet

Post by wolph42 »

CoveredInFish wrote:

Code: Select all

[h:foreach(state,statesList), if(getState(state)):true_body]
and your still forgetting one :
it should be

Code: Select all

[h,foreach(state,statesList), if(getState(state)):true_body]
that and its not recommended to use two 'functional' roll options in one line of code as that will not always work. Read my 'working with two code levels' article linked in sig for more info. Note that in this particular case (with the right syntax) the above line should work. But e.g. [if(), foreach():function] won't work!!

One of the most important parts of MT script to hammer into your head is the basic syntax:

[rollOption, rollOption, (...), rollOption: function()]

so many roll options, only 1 function preceded by one ":"

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: Displaying Current Token States on Property Sheet

Post by CoveredInFish »

wolph42 wrote:and your still forgetting one
DOH! It seems it was still to early for me to think ... :?

Thanks for fixing!

Post Reply

Return to “Macros”