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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
mikele
Beginner


Joined: 10 Nov 2006
Posts: 20
Location: China

PostPosted: Fri Dec 01, 2006 6:21 am   

How can I use variable like this in CMUD?
 
I created 4 variables:number_a,number_b,number_c and id.
I created a trigger:#tri {(%w) killed (%d) people} {id=%1;#add number_@whoid 1;#sh @number_whoid}.
The variable "id" may be "a" or "b" or "c".I want use this trigger to statistic the score of my three ID's.
It worked very nice in zmud,but is no use in cmud now.
How cna I make it useful again?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Dec 01, 2006 8:45 am   
 
I tested this by creating two variables @number_1 with no value and @whoid with value "1", and an alias test that ran {#addkey number_@whoid $param} and it added the numbers just fine. The #show part you have there won't work, though, because @number_whoid isn't a valid variable - you want to reference the variable you just added something to, right? Also, you haven't actually defined the variable @whoid anywhere in this script, so just make sure that whoid is being set right and that it's enabled and visible to the module that's looking for it.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
mikele
Beginner


Joined: 10 Nov 2006
Posts: 20
Location: China

PostPosted: Fri Dec 01, 2006 8:58 am   
 
Sorry,I'm afraid I take a clerical error in my describing.
The right trigger I mean is::#tri {(%w) killed (%d) people} {id=%1;#add number_@id 1;#sh @number_@id}.
So,the variable number_@id may be number_a or number_b or number_c.It will be decided by captured text.
Reply with quote
mikele
Beginner


Joined: 10 Nov 2006
Posts: 20
Location: China

PostPosted: Fri Dec 01, 2006 9:04 am   
 
I don't know it's good idea that use underline in variable name.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Dec 01, 2006 9:14 am   
 
Yes, as far as I can see, the #add part is working fine, it's the #show part that isn't, because it's looking for @number_, a variable that doesn't exist. What you need to do is change it to @{number_@id} so that the script knows the @id is part of the variable name and not the start of a new variable. The final script you'll get will look like this:

#tri {(%w) killed (%d) people} {id=%1;#add number_@id 1;#sh @{number_@id}}

One thing you might want to do is get rid of the @id variable and change the script to use local variables:

#tri {($id:%w) killed (%d) people} {#add number_$id 1;#sh @{number_$id}}
Reply with quote
mikele
Beginner


Joined: 10 Nov 2006
Posts: 20
Location: China

PostPosted: Fri Dec 01, 2006 9:21 am   
 
Yeah!The problem have been solved!Thank you very much!
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Dec 01, 2006 6:09 pm   
 
And yes, the _ underscore is perfectly valid in variables, aliases, etc.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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