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
Thanaa
Newbie


Joined: 28 May 2009
Posts: 2

PostPosted: Thu May 28, 2009 2:34 pm   

expression in a variable
 
Im trying to convert some old zmud stuff to cmud, and im running into 1 small problem.

I have a variable that holds this:

%if( @Afflictions.bound == 1 or @Afflictions.impaled == 1 or @Afflictions.roped == 1 or @Afflictions.transfixed == 1 or @Afflictions.webbed == 1, " <color brown>Tangled</color>", "")

However in cmud, it doesn't seem to be evaluating, i've tried #exec with no luck, any suggestions?
Reply with quote
Aidan88
Beginner


Joined: 18 May 2009
Posts: 11

PostPosted: Thu May 28, 2009 5:40 pm   
 
Have you tried using just one "equal" expression?
Reply with quote
Thanaa
Newbie


Joined: 28 May 2009
Posts: 2

PostPosted: Thu May 28, 2009 5:59 pm   
 
What do you mean? like just @Afflictions.bound == 1
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu May 28, 2009 7:50 pm   
 
Perhaps you are looking for #eval? How do you intend to use this variable? Actually, this is technically a varfunc, not a pure variable.
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Thu May 28, 2009 9:14 pm   
 
I may be wrong because I haven't had time for ages to code in CMud, but most likely what you'd need is #FUNC

It'd have code along those lines as a value:

Code:

#if (@Afflictions.bound=1 OR @Afflictions.impaled=1 OR @Afflictions.roped=1 OR @Afflictions.transfixed=1 OR @Afflictions.webbed=1) {
#RETURN "<color brown>Tangled</color>"}
{
//something else
}


I'm not sure, however, if the dot notation works or not. Maybe use some %db function there instead.

My two cents. hope it helps some.
_________________
The Proud new owner of CMud.

--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
--------------------------------
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Fri May 29, 2009 12:00 am   
 
I have no problem running this code. Your problem likely stems from the fact that #function is different in CMUD, as the other posters have pointed out. The CMUD equivalent of the old function command is #varfunc and using it will likely solve your problems. There's probably one or more of a number of things wrong with the variable you have created:

1) It's not a variable at all, it's a function. The code that would be valid in a varfunc isn't valid in a proper function.
2) Your code may have accidentally been expanded when the function was compiled, leading some of the variable references not to work. You can see that yourself if you have a look at the contents of the variable.
3) The variable's type may be wrong. It needs to be "String (expanded)" and not any of the other options including "AutoType".

The following XML shows my variable, which is working fine when I type #addkey afflictions bound 1;#say @test on the command line:

Code:
<var name="test" type="String">%if(  @Afflictions.bound == 1 or  @Afflictions.impaled == 1 or  @Afflictions.roped == 1 or  @Afflictions.transfixed == 1 or  @Afflictions.webbed == 1,  " Tangled",  "")</var>


Your browser may be displaying the < and > characters in this XML. It may also be eating the <color> tags entirely, thinking that they're HTML. If that's the case, quote my post and copy it from there.

I created this function by typing on the command line #varfunc test {%if( @Afflictions.bound == 1 or @Afflictions.impaled == 1 or @Afflictions.roped == 1 or @Afflictions.transfixed == 1 or @Afflictions.webbed == 1, " <color brown>Tangled</color>", "")} and that was it.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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