Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Prompt Trigger Problems

Prompt Trigger Problems

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2 

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #15 on Thu 20 Oct 2011 07:20 AM (UTC)
Message
Get the capitalization right. \d is a digit \D is not a digit.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Warbit   USA  (47 posts)  Bio
Date Reply #16 on Thu 20 Oct 2011 07:28 AM (UTC)

Amended on Thu 20 Oct 2011 07:32 AM (UTC) by Warbit

Message
Ok fix capitalization.
deleted MY from MyHpNeeded.
So both if statements are HpNeeded


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="Prompt"
   match="^\&lt;(\d+)\/(\d+)Hp (\d+)\/(\d+)Ma (\d+)\/(\d+)Mv AC\:([0-9+-]) Continent\:(.*?) Weather\:(.*?)\&gt;$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>Chp = %1
MHp = %2 
CMa = %3
MMa = %4
CMv = %5
MMv = %6




Hpneeded = MHp - CHp

if %7&gt;-5 then
Send("|")
Send("cast 'stone skin'")
end--if

if IsHungry =="Yes" then
Send("cast 'create food'")
Send("get food")
Send("get food mass")
Send("eat food")
end--if

if IsThirsty =="Yes" then
Send("get barrel mass")
Send("drink barrel")
Send("cast 'create water' barrel")
end--if



if HpNeeded&gt;16 and CMa&gt;16 then
Send("cast 'cure minor'")
end--if

if HpNeeded &gt; 77 and CMa&gt; 77 then
Send("cast 'cure normal'")
end--if</send>
  </trigger>
</triggers>


Still not firing.

Found and corrected Capitalization error, in Hpneeded
changed to HpNeeded

Current Trigger still not firing.

<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="Prompt"
   match="^\&lt;(\d+)\/(\d+)Hp (\d+)\/(\d+)Ma (\d+)\/(\d+)Mv AC\:([0-9+-]) Continent\:(.*?) Weather\:(.*?)\&gt;$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>Chp = %1
MHp = %2 
CMa = %3
MMa = %4
CMv = %5
MMv = %6




HpNeeded = MHp - CHp

if %7&gt;-5 then
Send("|")
Send("cast 'stone skin'")
end--if

if IsHungry =="Yes" then
Send("cast 'create food'")
Send("get food")
Send("get food mass")
Send("eat food")
end--if

if IsThirsty =="Yes" then
Send("get barrel mass")
Send("drink barrel")
Send("cast 'create water' barrel")
end--if



if HpNeeded&gt;16 and CMa&gt;16 then
Send("cast 'cure minor'")
end--if

if HpNeeded &gt; 77 and CMa&gt; 77 then
Send("cast 'cure normal'")
end--if</send>
  </trigger>
</triggers>

Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #17 on Thu 20 Oct 2011 08:20 AM (UTC)

Amended on Thu 20 Oct 2011 08:21 AM (UTC) by Nick Gammon

Message
Under AC you forgot to allow for the decimal point, plus you have to have "one or more" (a + sign) after it. This fires:


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="Prompt"
   match="^\&lt;(\d+)\/(\d+)Hp (\d+)\/(\d+)Ma (\d+)\/(\d+)Mv AC\:([0-9+\-\.]+) Continent\:(.*?) Weather\:(.*?)\&gt;$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>Chp = %1
MHp = %2 
CMa = %3
MMa = %4
CMv = %5
MMv = %6




HpNeeded = MHp - CHp

if %7&gt;-5 then
Send("|")
Send("cast 'stone skin'")
end--if

if IsHungry =="Yes" then
Send("cast 'create food'")
Send("get food")
Send("get food mass")
Send("eat food")
end--if

if IsThirsty =="Yes" then
Send("get barrel mass")
Send("drink barrel")
Send("cast 'create water' barrel")
end--if



if HpNeeded&gt;16 and CMa&gt;16 then
Send("cast 'cure minor'")
end--if

if HpNeeded &gt; 77 and CMa&gt; 77 then
Send("cast 'cure normal'")
end--if</send>
  </trigger>
</triggers>

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Warbit   USA  (47 posts)  Bio
Date Reply #18 on Thu 20 Oct 2011 08:37 AM (UTC)
Message
Thanks Nick for rewrite but am getting this error.


Error number: 0
Event:        Run-time error
Description:  [string "Trigger: "]:11: attempt to perform arithmetic on global 'CHp' (a nil value)

stack traceback:

	[string "Trigger: "]:11: in main chunk
Called by:    Immediate execution

Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #19 on Thu 20 Oct 2011 11:00 AM (UTC)
Message
I got that too, but at least the trigger matched.

As to why, get the capitalization right, as I said before. Check the way you spelt that variable in two places.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Warbit   USA  (47 posts)  Bio
Date Reply #20 on Thu 20 Oct 2011 11:35 AM (UTC)
Message
Ahhh !!! First CHp is wrong too.

<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="Prompt"
   match="^\&lt;(\d+)\/(\d+)Hp (\d+)\/(\d+)Ma (\d+)\/(\d+)Mv AC\:([0-9+\-\.]+) Continent\:(.*?) Weather\:(.*?)\&gt;$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>CHp = %1
MHp = %2 
CMa = %3
MMa = %4
CMv = %5
MMv = %6




HpNeeded = MHp - CHp

if %7&gt;-5 then
Send("|")
Send("cast 'stone skin'")
end--if

if IsHungry =="Yes" then
Send("cast 'create food'")
Send("get food")
Send("get food mass")
Send("eat food")
end--if

if IsThirsty =="Yes" then
Send("get barrel mass")
Send("drink barrel")
Send("cast 'create water' barrel")
end--if



if HpNeeded&gt;16 and CMa&gt;16 then
Send("cast 'cure minor'")
end--if

if HpNeeded &gt; 77 and CMa&gt; 77 then
Send("cast 'cure normal'")
end--if</send>
  </trigger>
</triggers>

re-enabled so far no errors. but will need to remove work arounds. To see if it works.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #21 on Thu 20 Oct 2011 08:33 PM (UTC)
Message
I would start indenting a bit, it makes it easier to debug. Also have you heard of multi-line literals? Instead of:


if IsHungry =="Yes" then
Send("cast 'create food'")
Send("get food")
Send("get food mass")
Send("eat food")
end--if


You can (if you wish) do:


if IsHungry == "Yes" then
Send([[
cast 'create food'
get food
get food mass
eat food]])
end--if

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Warbit   USA  (47 posts)  Bio
Date Reply #22 on Thu 20 Oct 2011 09:44 PM (UTC)
Message
AHHH Cool !!!
No never heard of it, but I will definitely use it.

Also I believe Trigger works perfectly!!! Thanks again for all your time and help. I will start indenting too. I did not know language would allow me to.

I know I will break prompt trigger again since I want to do so much more with it. It seems the perfect place to place, most of my character's future functionality.

I also plan on trying to tackle your tables tutorials. But that is a problem for a different thread. Thanks again 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.


72,122 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.