TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Substitution with variables [Solved]

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help
View previous topic :: View next topic  
Author Message
cynric



Joined: 06 Mar 2011
Posts: 2

PostPosted: Sun Mar 06, 2011 9:48 pm    Post subject: Substitution with variables [Solved] Reply with quote

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
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3274

PostPosted: Sun Mar 06, 2011 11:21 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
cynric



Joined: 06 Mar 2011
Posts: 2

PostPosted: Sun Mar 06, 2011 11:26 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help All times are GMT - 5 Hours
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
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group