Need help with a macro for adding states to a token.

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
User avatar
Oryan77
Dragon
Posts: 452
Joined: Sun Feb 20, 2011 3:14 pm

Need help with a macro for adding states to a token.

Post by Oryan77 »

Could someone help me create this macro:

Window appears with radial buttons numbered 1-10 (so 10 radial buttons). Depending on which radial button is selected, a corresponding state image appears on the token. Assume each state is named; A1, A2, A3, etc, etc to match up with the radial button numbers. So selecting radial button 1 causes state image A1 to appear on the token. Also, regardless of what radial button is clicked, another state image will also appear on the token. This image could be called X1. So using this macro causes 2 images at once to appear on the token.

If I use the macro again on the same token, the previously selected radial button will be selected. Selecting a different radial button will change the state image on the token.

Finally, above the radial buttons would be some sort of ability to select an "End Status" function that will clear the states associated with this macro but not any other states currently on the token. This could be another radial button, or a new button that when pressed, closes the window and removes the states for this macro.

Is this possible? Thanks!

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

Re: Need help with a macro for adding states to a token.

Post by wolph42 »

roughly something like this:

Code: Select all

[assert(listCount(getSelectedNames())==1, "Make sure only one token is selected",0)]
[switchToken(getSelectedNames())]
[oldNumberState    = 0]
[count(11),if(getState("A"+roll.count)):oldNumberState = roll.count]
[abort(input("numberState|none,1,2,3,4,5,6,7,8,9,10|Which Number State|RADIO|ORIENT=V SELECT="+oldNumberState))]
[count(11):setState("A"+roll.count,0)]
[if(numberState), CODE:{
    [setState("A"+numberState,1)]
    [setState("X1",1)]
};{
    [setState("X1",0)]
}] 
UNTESTED!!

edited!

User avatar
Oryan77
Dragon
Posts: 452
Joined: Sun Feb 20, 2011 3:14 pm

Re: Need help with a macro for adding states to a token.

Post by Oryan77 »

wolph42 wrote:UNTESTED!!
So I get this message:

Code: Select all

 Invalid condition in IF(getState("A"+roll.count)) roll option.       Statement options (if any): count(11),if(getState("A"+roll.count))       Statement Body : oldNumberState = roll.count
Just so you know what I did on my end, my states are named A1, A2, A3, A4, A5, A6, A7, A8, A9, A10. The other state is named X1. I think I have that matching correctly with your code.

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

Re: Need help with a macro for adding states to a token.

Post by wolph42 »

I think you need to create an a0 as well for it to work. If a state does not exist and you check for it it renders an error, which is passed on to the if statement

User avatar
Oryan77
Dragon
Posts: 452
Joined: Sun Feb 20, 2011 3:14 pm

Re: Need help with a macro for adding states to a token.

Post by Oryan77 »

That did it. However, the previous "A" states are not replaced when the macro is used again. The states stack on top of each other. Using the "none" button removes them, but only one at a time. So I need to keep using the macro to remove them.

This text also appears in the chat window in case it is a separate issue:

Code: Select all

« assert(listCount(getSelectedNames())==1, "Make sure only one token is selected",0) = 1 » « switchToken(getSelectedNames()) = switchToken(getSelectedNames()) =  » « oldNumberState = 0 = oldNumberState = 0 = 0 » « '' = '' =  », « oldNumberState = roll.count = oldNumberState = 1 = 1 », « '' = '' =  », « '' = '' =  », « '' = '' =  », « '' = '' =  », « '' = '' =  », « '' = '' =  », « '' = '' =  », « '' = '' =  », « '' = '' =  » « abort(input("numberState|none,1,2,3,4,5,6,7,8,9,10|Which Number State|RADIO|ORIENT=V SELECT="+oldNumberState)) = abort(input("numberState|none,1,2,3,4,5,6,7,8,9,10|Which Number State|RADIO|ORIENT=V SELECT=" + 1)) = 1 » « setState("A"+numberState,1) = setState("A" + 2, 1) = 1 » « setState("X1",1) = setState("X1", 1) = 1 »

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

Re: Need help with a macro for adding states to a token.

Post by wolph42 »

Need to think about the former(note that you can use am's choose from the other post to turn the states off. As for the latter either
Put h: in [h:
Or bluntly insert abort(0) at the end


User avatar
Oryan77
Dragon
Posts: 452
Joined: Sun Feb 20, 2011 3:14 pm

Re: Need help with a macro for adding states to a token.

Post by Oryan77 »

Hmm, I still get the same result (numbers not getting replaced when the macro is used again). The "none" button also doesn't clear anything any longer. The chat window reports back with "Undefined function: count".


User avatar
Oryan77
Dragon
Posts: 452
Joined: Sun Feb 20, 2011 3:14 pm

Re: Need help with a macro for adding states to a token.

Post by Oryan77 »

I got the same results as before including the "Undefined function: count" error.


User avatar
Oryan77
Dragon
Posts: 452
Joined: Sun Feb 20, 2011 3:14 pm

Re: Need help with a macro for adding states to a token.

Post by Oryan77 »

It still does not remove the old "A" states when adding the new "A" states. Although, this time when I click on "none" it does remove X1 and all of the "A" states that are currently appearing on the token.

Do I by chance need to have an identifier somehow in the Basics token property for this to work? I'm just wondering if this macro needs to store the "A" token info in the token Basic property in order for the new "A" to replace the old "A".


User avatar
Oryan77
Dragon
Posts: 452
Joined: Sun Feb 20, 2011 3:14 pm

Re: Need help with a macro for adding states to a token.

Post by Oryan77 »

wolph42 wrote:you didnt say that you wanted that
My 3rd post down mentioned the A states not being removed. Which was what I thought you were trying to get working this whole time. :P

Sorry if I confused you. Works perfectly now though! Thank you so much.


Post Reply

Return to “Macros”