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
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Fri Nov 07, 2008 5:06 pm   

Using Concat for variables
 
Code:

ID: SPcolor
%concat(Pcolor,%1)=%-2
#say Player Color %1 Set to: %concat(@Pcolor,%1)


I'm getting an illegal character error on =%-2, I was certain %-2 was what captured everything after %1, but it does not, am I using concat wrong?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri Nov 07, 2008 5:34 pm   
 
Not using it wrong, but not using it correctly, either. You need to quote strings, even if it's a variable without the @

You'll probably not want to use the = syntax here. Instead, do:
#VAR %concat("Pcolor", %1) %-2

Charneus
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Fri Nov 07, 2008 6:14 pm   
 
What's the difference, specifically?

Putting quotes around the variable in this:
Code:

#say Player Color %1 Set to: %concat("@Pcolor",%1)

Just shows the variable's name, but if it isn't in quotes then I get back a result of one when I enter

Pcolor 1 #FFFFF
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Fri Nov 07, 2008 7:07 pm   
 
Because your "@Pcolor" is a literal string, and you haven't told CMUD to expand it anywhere. Use @{%concat("Pcolor",%1)} instead.

Oh, and the difference between = and #var is that #var will work in this case and = won't. You should use #var for dynamic variable names like this case.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri Nov 07, 2008 7:47 pm   
 
Not to mentiom you cannot start a command with a function, really. Starting a line with a function is bound to return problems down the road. Each new line needs to start with a CMUD command, alias, or a var=value syntax. That's why there is a #RETURN command for functions now.

Charneus
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