|
Solaras Wanderer
Joined: 11 Mar 2002 Posts: 93
|
Posted: Wed Feb 28, 2007 8:20 pm
Unmatched braces error |
In zMUD this worked perfectly fine, however in cMUD I get an unmatched braces error in syntax checking.
Code: |
#if (@limb_hit~damage <= 0) {limb_hit~damage = 0} |
The unmatched is at col 45.
Now in fiddling, I have discovered that if I remove "~damage" it compiles fine. However, this affects the purpose of what I am trying to do. Am I missing something in the new cMUD where you can't append to a variable name using "~"? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Feb 28, 2007 8:38 pm |
I'm not sure what you're trying to do here. Having a special character as part of a variable name is going to cause problems, I really wouldn't recommend it.
If you're trying to assign a value to a variable whose name might change dependent on the script, you can use @{complex_@varname} or the like, and then use the #var command to assign a value to the variable using #var {complex_@varname} value. |
|
|
|
Solaras Wanderer
Joined: 11 Mar 2002 Posts: 93
|
Posted: Wed Feb 28, 2007 8:54 pm |
Ok let me try and explain fully.
In zMUD for years you could append to a variable name using the ~ character, this was very useful in situations where the variable itself may have a different value, but the appended portion was always static.
Example:
Limb targeting scripts. I want to keep track of how many hits I have made to a specific limb on a target. This means the @limb_hit value will change, but "damage" is the static portion appended.
So I hit the target's right arm, the variable @rightarmdamage will increase by 1.
In the example below it is assumed I received the message saying I missed. Meaning that @limb_hit~damage is decreased by 1.
Code: |
#ADD @limb_hit~damage -1
#if (@limb_hit~damage <= 0) {@limb_hit~damage = 0}
show_limbchart = 0 |
However, cMUD sadly seems to not allow this method. There is no special character as part of the variable name, @limb_hit~damage parses to be (assuming right arm was hit) @rightarmdamage. If the character has changed and I just haven't found it, great please tell me. If the means of appending to variable names is not allowed by cMUD, then I will just sulk and code a more cumbersome method. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Feb 28, 2007 9:08 pm |
I see, and yes that's what I'm talking to when I'm referring to the @{} syntax - in this case you'd do @{%concat(@limb_hit,damage)} and #var %concat(@limb_hit,damage) 0.
|
|
Last edited by Fang Xianfu on Wed Feb 28, 2007 10:18 pm; edited 1 time in total |
|
|
|
Solaras Wanderer
Joined: 11 Mar 2002 Posts: 93
|
Posted: Wed Feb 28, 2007 9:39 pm |
aha! Thanks muchly. Works like a charm.
|
|
|
|
|
|