 |
mikele Beginner
Joined: 10 Nov 2006 Posts: 20 Location: China
|
Posted: 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? |
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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.
|
|
|
|
 |
mikele Beginner
Joined: 10 Nov 2006 Posts: 20 Location: China
|
Posted: 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. |
|
|
|
 |
mikele Beginner
Joined: 10 Nov 2006 Posts: 20 Location: China
|
Posted: Fri Dec 01, 2006 9:04 am |
I don't know it's good idea that use underline in variable name.
|
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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}} |
|
|
|
 |
mikele Beginner
Joined: 10 Nov 2006 Posts: 20 Location: China
|
Posted: Fri Dec 01, 2006 9:21 am |
Yeah!The problem have been solved!Thank you very much!
|
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Dec 01, 2006 6:09 pm |
And yes, the _ underscore is perfectly valid in variables, aliases, etc.
|
|
|
|
 |
|
|
|