Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Arthaey
Beginner


Joined: 13 Apr 2001
Posts: 15
Location: USA

PostPosted: Wed Jan 16, 2002 6:54 am   

Buttons made by aliases (alii? :)
 
I'm making a card game script where each player's hand is a list, eg {Card1|Card2|Card3}. I want to make a multistate "Play Card" button that is created by an alias, say "Rebutton", where each state is an individual card in that player's hand.

Is this possible? I tried using a #LOOP function in defining the button:

#ALIAS Rebutton {#BUTTON 1 {Play Card} {} {#LOOP %numitems(@playerHand) {%item(@playerHand},%i)|}} <insert rest of button props here> }

but that just put the literal "#LOOP blah blah" as the state caption.


--
Arthaey
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Jan 16, 2002 5:44 pm   
 
You are trying to make a stringlist with the #LOOP command, right? It appears from your use of the %numitems(@playerHand) that @playerHand is already a stringlist with precisely the values you want. Why not just use it?

LightBulb
All scripts untested unless otherwise noted
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Jan 17, 2002 12:33 am   
 
Your rebutton alias would have to be something like this:
#EXEC %expand(#BUTTON 1 {Play Card} {} {@playershand} {%concat("PlayCardAlias",%replace(@playershand,"|","|PlayCardAlias "))} {} {} {} {} {} {} {} {} {} {} {0|0|0|0|0|0|0} {} {} "" {} {} {PlayCard}

You would have to write the PlayCardAlias or change the name in there to what you have. Note that this may have some odd effects do to the replace with the list seperator. Currently it is allowed but may be a problem in future versions.
Reply with quote
Arthaey
Beginner


Joined: 13 Apr 2001
Posts: 15
Location: USA

PostPosted: Thu Jan 17, 2002 12:44 am   
 
I tried your suggestion, but when I run the alias

#button 1 {Play Card} {} {@playerHand} {@playerHand}

to make the button, it outputs a toggle button with "Play Card" as one state and the literal caption "@playerHand" as the other state. The variable is not expanded out to its list form. I tried substituting %expand(@playerHand) for @playerHand, but that didn't work either.

I hadn't mentioned earlier that the actual variable that I'm using is @player@{meNum}Hand -- a variably named variable. I hadn't thought it was important, since it doesn't work with either form of the variable name. But just in case it -does- make a difference, I thought I might as well let you know what I'm really using.

To sum up, the question boils down to this: How can I force the variable to expand before its values are put into the button?


--
Arthaey
Reply with quote
Arthaey
Beginner


Joined: 13 Apr 2001
Posts: 15
Location: USA

PostPosted: Thu Jan 17, 2002 12:52 am   
 
quote:

Your rebutton alias would have to be something like this:
#EXEC %expand(#BUTTON 1 {Play Card} {} {@playershand} {%concat("PlayCardAlias",%replace(@playershand,"|","|PlayCardAlias "))} {} {} {} {} {} {} {} {} {} {} {0|0|0|0|0|0|0} {} {} "" {} {} {PlayCard}



I tried that (and added a closing parenthese at the very end to close up the %expand function), but all it did was create 7 empty states -- no captions, no commands. So, at least it's a step in the right direction, but it's still not working properly. :(


--
Arthaey
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Jan 17, 2002 12:56 am   
 
Ahh I see I should have typed PlayerHand, I have PlayersHand. Also I couldn't figure what the section in the button with 0|0|0|0|0 does. probably you should replace that with "%leftback(%repeat("0|",%numitems(@PlayerHand)),1)" Sorry bout the typo
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Jan 17, 2002 12:57 am   
 
Ahh I see I should have typed PlayerHand, I have PlayersHand. Also I couldn't figure what the section in the button with 0|0|0|0|0 does. probably you should replace that with "%leftback(%repeat("0|",%numitems(@PlayerHand)),1)" Sorry bout the typo
Reply with quote
Arthaey
Beginner


Joined: 13 Apr 2001
Posts: 15
Location: USA

PostPosted: Thu Jan 17, 2002 8:27 am   
 
Thank you all for your help. I've got it working now.


Thanks again!
--
Arthaey
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net