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

Automatic substitution of only certain variables.

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



Joined: 01 Nov 2010
Posts: 5

PostPosted: Thu Aug 24, 2017 8:49 am    Post subject: Automatic substitution of only certain variables. Reply with quote

Ok, I know about #line substitute variable, and about escape characters, but somehow I can not find the proper combination of escapes to make it works as intended by me.

I have a list of objects in this form
Code:

#var objectsDonate
{
  {shortName1}{longName1};
  {shortName2}{longName2};
  ...
}


for each of them I want to create an action that add the shortname to a pile everytime "You take $longName". I wrote this:

Code:

#foreach $objectsDonate[] {shortName}
{
  #action {You take $objectsDonate[$shortName]}
  {
    #math numbOD {$numbOD +1};
    #var readyOD[$numbOD] $shortName;
  }
}


With this however, I get a series of actions that are like this:

Code:

#action {You take longName1}
{
  #math numbOD {$numbOD +1};
  #var readyOD[$numbOD] $shortName;
}

Everything is fine, but I would want instead of the last "$shortName" the corresponding value.
How to substitute only the $shortname, while leaving $numbOD untouched?

Thanks!
Back to top
View user's profile Send private message
PowerGod



Joined: 04 Aug 2014
Posts: 339

PostPosted: Fri Aug 25, 2017 3:41 pm    Post subject: Reply with quote

A way is to add another "$" to all the vars you don't want to be substituted:

Code:

#foreach $objectsDonate[] {shortName} {
    #line substitute variables #action {You take $objectsDonate[$shortName]} {
        #math numbOD {$$numbOD +1};
        #var readyOD[$$numbOD] $objectsDonate[$shortName];
    }
}
Back to top
View user's profile Send private message
bobon123



Joined: 01 Nov 2010
Posts: 5

PostPosted: Fri Aug 25, 2017 6:49 pm    Post subject: Reply with quote

Thanks, it works perfectly!
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