[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Prompt Trigger Problems

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Prompt Trigger Problems

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Pages: 1  2 

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Reply #15 on Thu 20 Oct 2011 07:20 AM (UTC)  quote  ]
Message
Get the capitalization right. \d is a digit \D is not a digit.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Warbit   USA  (47 posts)  [Biography] bio
Date Reply #16 on Thu 20 Oct 2011 07:28 AM (UTC)  quote  ]

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>

[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Reply #17 on Thu 20 Oct 2011 08:20 AM (UTC)  quote  ]

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
[Go to top] top

Posted by Warbit   USA  (47 posts)  [Biography] bio
Date Reply #18 on Thu 20 Oct 2011 08:37 AM (UTC)  quote  ]
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

[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Reply #19 on Thu 20 Oct 2011 11:00 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Warbit   USA  (47 posts)  [Biography] bio
Date Reply #20 on Thu 20 Oct 2011 11:35 AM (UTC)  quote  ]
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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Reply #21 on Thu 20 Oct 2011 08:33 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Warbit   USA  (47 posts)  [Biography] bio
Date Reply #22 on Thu 20 Oct 2011 09:44 PM (UTC)  quote  ]
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!
[Go to top] 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.


2,272 views.

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

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]