Trigger text.

Posted by Chaosmstr on Wed 10 Sep 2014 11:46 PM — 3 posts, 12,766 views.

#0
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>

Amended on Thu 11 Sep 2014 09:10 AM by Nick Gammon
Australia Forum Administrator #1
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".
#2
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!