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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Solaras
Wanderer


Joined: 11 Mar 2002
Posts: 93

PostPosted: 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 "~"?
Reply with quote
Fang Xianfu
GURU


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

PostPosted: 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.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Solaras
Wanderer


Joined: 11 Mar 2002
Posts: 93

PostPosted: 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.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: 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
Reply with quote
Solaras
Wanderer


Joined: 11 Mar 2002
Posts: 93

PostPosted: Wed Feb 28, 2007 9:39 pm   
 
aha! Thanks muchly. Works like a charm.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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