eval() is weird (input() PROPS/CHECKBOX combo?)

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
Mrugnak
Dragon
Posts: 745
Joined: Mon Jul 21, 2008 7:38 pm

eval() is weird (input() PROPS/CHECKBOX combo?)

Post by Mrugnak »

I'm going bonkers trying to roll this by hand, but perhaps there's already a way to do this. I hope.

Is there a way to do something like the PROPS option in an input() box, but it displays a list of checkboxes (ideally with text and images) and creates the PROPS variables?

Goal:
Take in list of selected tokens
Present tokens (with names and pictures) to player with checkboxes. Allow them to select zero, one, or many of the tokens.
Get the results of this.

Current status:
:? Confused

I can get the list of selected tokens, and via a FOR loop and some HTML in the CHECK labels I can build an input() that displays each token by name and picture, with checkboxes. That all works. eval() is being difficult and won't let me check the value of ... anything, really.

Code: Select all

[h:count0 = "Q"] [h:count1 = "R"][h:countOfTokens=2][for(x,0,countOfTokens): eval("count" + string(x))]
If I run that, I expected it to print out "Q, R" without prompting me for anything.
Instead, it prompts me for the values of count0 and then count1, and prints out what I entered, if anything. SO apparently this isn't a thing? It's bizarre, because Eval is clearly putting together the string correctly, and is clearly understanding that it's a variable... but can't figure out that it's an EXISTING variable.
Last edited by Mrugnak on Wed Jan 18, 2017 1:30 pm, edited 1 time in total.

User avatar
Mrugnak
Dragon
Posts: 745
Joined: Mon Jul 21, 2008 7:38 pm

Re: input() PROPS/CHECKBOX combo?

Post by Mrugnak »

If I do without the for loop

Code: Select all

[h:count0 = "Q"] [h:count1 = "R"] [eval("count" + string("0"))]
or

Code: Select all

[h:count0 = "Q"] [h:count1 = "R"] [eval("count0")]
it still doesn't work. I can do

Code: Select all

[h:count0 = "Q"] [h:count1 = "R"] [count0]
and it works as expected (prints Q)

If I do

Code: Select all

[h:count0 = "Q"] [h:count1 = "R"] [eval(count0)]
it also works as expected, prompting me for the value of a new variable, Q.

so, vat der hey?

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

Re: eval() is weird (input() PROPS/CHECKBOX combo?)

Post by aliasmask »

Mrugnak wrote:

Code: Select all

[h:count0 = "Q"] [h:count1 = "R"][h:countOfTokens=2][for(x,0,countOfTokens): eval("count" + string(x))]
If I run that, I expected it to print out "Q, R" without prompting me for anything.
Instead, it prompts me for the values of count0 and then count1, and prints out what I entered, if anything. SO apparently this isn't a thing? It's bizarre, because Eval is clearly putting together the string correctly, and is clearly understanding that it's a variable... but can't figure out that it's an EXISTING variable.
This works as expected. I simply copied the code to the chat and ran it. I also added it to a token with various settings and it also works. Btw, You don't need the string() call. eval("count"+x) works fine. How are you testing this?

User avatar
Mrugnak
Dragon
Posts: 745
Joined: Mon Jul 21, 2008 7:38 pm

Re: eval() is weird (input() PROPS/CHECKBOX combo?)

Post by Mrugnak »

aliasmask wrote:
Mrugnak wrote:

Code: Select all

[h:count0 = "Q"] [h:count1 = "R"][h:countOfTokens=2][for(x,0,countOfTokens): eval("count" + string(x))]
If I run that, I expected it to print out "Q, R" without prompting me for anything.
Instead, it prompts me for the values of count0 and then count1, and prints out what I entered, if anything. SO apparently this isn't a thing? It's bizarre, because Eval is clearly putting together the string correctly, and is clearly understanding that it's a variable... but can't figure out that it's an EXISTING variable.
This works as expected. I simply copied the code to the chat and ran it. I also added it to a token with various settings and it also works. Btw, You don't need the string() call. eval("count"+x) works fine. How are you testing this?
By copying the code to chat and running it. ????

I've got the server running as "GURPS Dungeon Fantasy Cat" password "gizmo" if anyone's around to have a poke at it.

User avatar
Mrugnak
Dragon
Posts: 745
Joined: Mon Jul 21, 2008 7:38 pm

Re: eval() is weird (input() PROPS/CHECKBOX combo?)

Post by Mrugnak »

Trey popped by and sorted me out. I had an old User Defined Function overriding eval() that was patching a bug in eval from I think the 1.3b40-odd era (I have it labeled as the Zero-Proof Eval fix if anyone remembers it). Clearly the patch is no longer beneficial, and the bug is probably fixed anyways :)

Remove the UDF eval() and voilla! sanity.

Post Reply

Return to “Macros”