Gammon Forum
Entire forum
MUSHclient
General
Trigger text.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| Chaosmstr
(21 posts) bio
|
Date
| Wed 10 Sep 2014 11:46 PM (UTC) Amended on Thu 11 Sep 2014 09:10 AM (UTC) by Nick Gammon
|
Message
| Ugh. So many iterations of something that seems simple.
Text I'm trying to trigger from:
<481hp(481) 462ma(462) 187mv(27829) s: ok 29565gp ft: none > You see nothing like that in the book.
I'm actually trying to trigger off of the "You see..." part.
It does not show up on a line by itself, cause that would be too easy. so I have to deal with a changing prompt at the head of the desired trigger phrase.
I've tried several iterations of "* You see..." with the * .* .*? etc.. and I cannot get it to trigger.
<triggers>
<trigger
enabled="y"
match="^(.*?) You see nothing like that in (.*?)$"
regexp="y"
send_to="12"
sequence="100"
>
<send>print("running")
getfd=GetVariable("getfd")
getwt=GetVariable("getwt")
if getfd==1 then
Send ("cast 'create food'")
else
if getwt==1 then
Send ("cast 'create water' $water \\n drink \\n drink \\n cast 'create water' $water \\n put $water $foodct")
end
end</send>
</trigger>
</triggers>
| top |
|
Posted by
| Nick Gammon
Australia (22,975 posts) bio
Forum Administrator |
Date
| Reply #1 on Thu 11 Sep 2014 09:16 AM (UTC) |
Message
| It triggered for me, but you have problems in your script. To tell the difference, make the trigger colour the matching text, at least then you know it fired.
I amended it to this, but even this isn't right:
print("running")
getfd = tonumber (GetVariable("getfd"))
getwt = tonumber (GetVariable("getwt"))
if getfd == 1 then
Send ("cast 'create food'")
else
if getwt == 1 then
Send ("cast 'create water' $water \\n drink \\n drink \\n cast 'create water' $water \\n put $water $foodct")
end
end
GetVariable returns strings, so they will never match 1 or 0. The "tonumber" part converts them to numbers.
I don't know that $water is supposed to be.
Variables should be put into scripts (in "send to script") as @variable (not $variable like Perl) so it should be @foodct not $foodct. And if you are going to do that you have to check "expand variables". |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Chaosmstr
(21 posts) bio
|
Date
| Reply #2 on Thu 11 Sep 2014 08:20 PM (UTC) |
Message
| Yes, the $ is supposed to be @.
Old habits from Wintin.
The Print command was supposed to run showing that the trigger fired off, but I like the coloring idea too.
I'll work it some more. Thanks for the input Nick! | top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
8,793 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
top
Quick links:
MUSHclient.
MUSHclient help.
Forum shortcuts.
Posting templates.
Lua modules.
Lua documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.