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

How can I generate an action with a variable?

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



Joined: 23 Jan 2017
Posts: 4

PostPosted: Thu Jan 26, 2017 10:10 pm    Post subject: How can I generate an action with a variable? Reply with quote

I am trying capture the location in the following line

Code:
  "a father                                                 Primate House"


where "Primate House" is the location.
and $cpmob already equals "a father" beforehand.


I am trying to use the following action to capture it, but it isn't quite working right. Do I need to escape my variable $cpmob some other way?

Code:
#ACTION {^%w%*$$cpmob %1}


Thanks in advance for the help!


Last edited by doctorly on Fri Jan 27, 2017 5:32 pm; edited 1 time in total
Back to top
View user's profile Send private message
PowerGod



Joined: 04 Aug 2014
Posts: 339

PostPosted: Fri Jan 27, 2017 5:08 pm    Post subject: Reply with quote

You should post an example of a full line where the action have to work

EDIT:

just a guess, maybe the action is missing upper-cases ?
Back to top
View user's profile Send private message
doctorly



Joined: 23 Jan 2017
Posts: 4

PostPosted: Fri Jan 27, 2017 5:33 pm    Post subject: Reply with quote

I did have it, but it got mangled.

Edited my original post to make it more understandable.

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



Joined: 04 Aug 2014
Posts: 339

PostPosted: Fri Jan 27, 2017 5:51 pm    Post subject: Reply with quote

if "cpmob" already contains the beginning of the line you don't need "%w%*"

Code:

#var cpmob {a father}
#OK. VARIABLE {cpmob} HAS BEEN SET TO {a father}.
#ACTION {^$cpmob %*} {#echo {LOCATION: %1}}
#OK. {^a father %*} NOW TRIGGERS {#echo {LOCATION: %1}} @ {5}.
#show {a father primate House}
LOCATION: primate House
a father primate House
Back to top
View user's profile Send private message
doctorly



Joined: 23 Jan 2017
Posts: 4

PostPosted: Sat Jan 28, 2017 12:25 am    Post subject: Reply with quote

Actually I think the problem is related to having an action nested inside of an alias.

The following doesn't work, and I think it is because '%1' and '%2' are expected to be variables from the alias.

How can I access the value from the last wildcard in regex?

Code:
#alias {create_ac}
{
  #ACTION {^%*$cpmob %*}
  {
    #echo {this is a test};
    #echo {LOCATION: %1};
    #echo {LOCATION: %2};
  }
}


when I run the above alias, it generates the following action, with the %1 and %2 variables missing.

Code:

  #ACTION {^%*$cpmob %*}
  {
    #echo {this is a test};
    #echo {LOCATION: };
    #echo {LOCATION: };
  }


PowerGod: your version did get me inside of the action when I used '%*' instead of '%1' which led me to the real problem.
Back to top
View user's profile Send private message
PowerGod



Joined: 04 Aug 2014
Posts: 339

PostPosted: Sat Jan 28, 2017 4:56 am    Post subject: Reply with quote

oh, if that's the case then you need to use a double "%" (and if them are inside something else a triple "%", etc...)

so "%%1" and "%%2"
Back to top
View user's profile Send private message
doctorly



Joined: 23 Jan 2017
Posts: 4

PostPosted: Mon Jan 30, 2017 11:04 am    Post subject: Reply with quote

That works, thanks a lot!
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