| View previous topic :: View next topic |
| Author |
Message |
cynric
Joined: 06 Mar 2011 Posts: 2
|
Posted: Sun Mar 06, 2011 9:48 pm Post subject: Substitution with variables [Solved] |
|
|
I am attempting to create a substitution which uses a variable. The general format of the original string is "You X Y with your sword." This could be accomplished with using %1 and %2, however each can be multiple words. X is a damage message and the idea was to set it as a variable. Y is fine as a %2.
The following was used:
| Code: |
#variable {damageMsg} {scratch|graze|\e[0;32mmaim\e[0m| \e[1;31m :::: HURT :::: \e[0m }
#sub {~^You {$damageMsg} %2 with your ghastly curse! %3} {Curse %2 for %3}
|
Is there an obvious syntax error? Thanks for any suggestions.
Last edited by cynric on Sun Mar 06, 2011 11:26 pm; edited 1 time in total |
|
| Back to top |
|
 |
Scandum Site Admin
Joined: 03 Dec 2004 Posts: 3274
|
Posted: Sun Mar 06, 2011 11:21 pm Post subject: |
|
|
Keep in mind that everything nested in the second set of braces is treated as a full regular expression.
I'm not exactly sure why, but if you escape the square brackets it ought to work alright:
| Code: |
#variable {damageMsg} {scratch|graze|\e\[0;32mmaim\e\[0m| \e\[1;31m :::: HURT :::: \e\[0m }
|
|
|
| Back to top |
|
 |
cynric
Joined: 06 Mar 2011 Posts: 2
|
Posted: Sun Mar 06, 2011 11:26 pm Post subject: |
|
|
| Many thanks for the speedy response. That did in fact do the trick. Greatly appreciated -- probably would not have realized that about the nesting. |
|
| Back to top |
|
 |
|