 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: 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? |
|
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: 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 |
|
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: 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 |
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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. |
|
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: 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 |
|
|
|
 |
|
|
|