[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 Warbit   USA  (47 posts)  [Biography] bio
Date Tue 11 Oct 2011 11:39 PM (UTC)  quote  ]
Message
I was trying to get my trigger to fire with the updating of my prompt. Right now it has many problems, but the problem I want to focus on now is that it is not Sending the command 'create food' on prompt update. Variable Hungry is Yes so the and mana is maxed. So there is no reason i see why, I am not sending 'create food'

This is my trigger

<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="Prompt"
   match="^\&lt;(\d+)\/(\d+)Hp (\d+)\/(\d+)Ma (\d+)\/(\d+)Mv AC\:\-(\d+) Continent\:(.*?) Weather\:(.*?)\&gt;$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable("CurHp","%1")
SetVariable("MaxHp","%2")
SetVariable("CurMana","%3")
SetVariable("MaxMana","%4")
SetVariable("CurMove","%5")
SetVariable("MaxMove","%6")
SetVariable("AC","%7")
SetVariable("Continent","%8")

SetVariable("InsideOutside","%9")

if "InsideOutside"~="indoors" then
SetVariable("InsideOutside","Outdoors")
end--if

HpNeeded = %2-%1

if "Hungry" ~="Yes" then
SetVariable("Hungry","No")
end--if

if "Thirsty" ~="Yes" then
SetVariable("Thirsty","No")
end--if



if "HpNeeded" &gt; 5 and "CurrentMana" &gt;16 then
Send("Cast 'cure light'")
end--if

-- create water                  - Lvl:  2, Mana:  5, Learned  

-- create food                   - Lvl:  3, Mana:  6, Learned  
if "Hungry"=="Yes" and "CurMana"&gt;12 then
Send("Cast 'create food'")
Send("Look")
end--if

-- cure minor                    - Lvl:  4, Mana:  8, Learned  
-- bless                         - Lvl:  5, Mana:  8, Learned  
-- shield of faith               - Lvl:  6, Mana: 35, Learned  
-- freshwater                    - Lvl:  4, Mana: 10, Learned  
-- goodberry                     - Lvl:  6, Mana:  7, Learned  
-- bone armor                    - Lvl: 11, Mana: 16, Learned  

</send>
  </trigger>
</triggers>


I am getting no errors since I converted to digits from wildcards. But trigger is not firing. I check that list of variables icon and it assures me Hungry Variable = "Yes". Though it is not updating for me being outside, but that's a problem for a later time.

QUESTION:
1. Why is trigger not firing?
2. How do I fix it?
[Go to top] top

Posted by Nick Gammon   Australia  (19,180 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Thu 13 Oct 2011 01:06 AM (UTC)  quote  ]
Message
Quote:

1. Why is trigger not firing?


You need to show (copy and paste) an example of your prompt before we could answer that.

This is completely wrong:


if "Hungry" ~="Yes" then
  SetVariable("Hungry","No")
end--if


The word "Hungry" will never be equal to the word "Yes".

Do you mean:



if GetVariable ("Hungry") ~="Yes" then
  SetVariable("Hungry","No")
end--if


Ditto for the other similar cases.

- Nick Gammon

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

Posted by Warbit   USA  (47 posts)  [Biography] bio
Date Reply #2 on Thu 13 Oct 2011 08:45 AM (UTC)  quote  ]

Amended on Thu 13 Oct 2011 09:13 AM (UTC) by Warbit

Message
Thanks Nick Making changes now.

Here is prompt.

<462/567Hp 104/104Ma 331/331Mv AC:-6.8 Continent:Ah Weather:indoors>

All one line.

Edited Prompt Trigger with your changes.

<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="Prompt"
   match="^\&lt;(\d+)\/(\d+)Hp (\d+)\/(\d+)Ma (\d+)\/(\d+)Mv AC\:\-(\d+) Continent\:(.*?) Weather\:(.*?)\&gt;$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable("CurHp","%1")
SetVariable("MaxHp","%2")
SetVariable("CurMana","%3")
SetVariable("MaxMana","%4")
SetVariable("CurMove","%5")
SetVariable("MaxMove","%6")
SetVariable("AC","%7")
SetVariable("Continent","%8")

SetVariable("InsideOutside","%9")

if GetVariable("InsideOutside")~="indoors" then
SetVariable("InsideOutside","Outdoors")
end--if

HpNeeded = %2-%1

if GetVariable("Hungry") ~="Yes" then
SetVariable("Hungry","No")
end--if

if GetVariable("Thirsty") ~="Yes" then
SetVariable("Thirsty","No")
end--if



if "HpNeeded" &gt; 5 and "CurMana" &gt;16 then
Send("Cast 'cure light'")
end--if

-- create water                  - Lvl:  2, Mana:  5, Learned  

-- create food                   - Lvl:  3, Mana:  6, Learned  
if GetVariable("Hungry")=="Yes" and GetVariable("CurMana")&gt;12 then
Send("Cast 'create food'")
Send("Look")
end--if

-- cure minor                    - Lvl:  4, Mana:  8, Learned  
-- bless                         - Lvl:  5, Mana:  8, Learned  
-- shield of faith               - Lvl:  6, Mana: 35, Learned  
-- freshwater                    - Lvl:  4, Mana: 10, Learned  
-- goodberry                     - Lvl:  6, Mana:  7, Learned  
-- bone armor                    - Lvl: 11, Mana: 16, Learned  

</send>
  </trigger>
</triggers>

[Go to top] top

Posted by Nick Gammon   Australia  (19,180 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Thu 13 Oct 2011 10:53 AM (UTC)  quote  ]
Message
I presume the trigger still isn't matching?

And I am a bit puzzled by this:


if GetVariable("Hungry") ~="Yes" then
  SetVariable("Hungry","No")
end--if



So if the variable Hungry is not Yes (ie. presumably it is No) then you set it to No. What does that achieve?

- Nick Gammon

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

Posted by Warbit   USA  (47 posts)  [Biography] bio
Date Reply #4 on Thu 13 Oct 2011 09:51 PM (UTC)  quote  ]
Message
well if hungry is anything but me being hungry then it will say no i am not hungry.

when i get hungry it will say yes

if it says yes then i will eat and set it to no,
till next time i am hungry.
[Go to top] top

Posted by Nick Gammon   Australia  (19,180 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Fri 14 Oct 2011 05:19 AM (UTC)  quote  ]

Amended on Fri 14 Oct 2011 05:20 AM (UTC) by Nick Gammon

Message
Apart from there, where does the variable "Hungry" get set ever?





if "HpNeeded" > 5 and "CurMana" > 16 then
  Send("Cast 'cure light'")
end--if


You are confusing variables with literals. You may as well write:



if 3 > 5 and 2 > 16 then
  Send("Cast 'cure light'")
end--if


You can see they will never be true?

- Nick Gammon

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

Posted by Warbit   USA  (47 posts)  [Biography] bio
Date Reply #6 on Wed 19 Oct 2011 07:33 AM (UTC)  quote  ]

Amended on Wed 19 Oct 2011 07:59 AM (UTC) by Warbit

Message
Thanks Nick.
Redid trigger and it is working.
Here is code. Took me a while to digest all you taught me. Working mostly trying to do the wait timer thing so that it casts spell once. Changes IsHungry Variable from yes to no and stops.

But here it is.


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="Prompt"
   match="&lt;*/*Hp */*Ma */*Mv AC:* Continent:* Weather:*&gt;"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable("CHp","%1")
SetVariable("MHp","%2")
SetVariable("CMa","%3")
SetVariable("MMa","%4")
SetVariable("CMv","%5")
SetVariable("MMv","%6")
SetVariable("AC","%7")
SetVariable("Continent","%8")
SetVariable("IndoorsOutdoors","%9")


CHp=GetVariable("CHp")
MHp=GetVariable("MHp")
CMa=GetVariable("CMa")
MMa=GetVariable("MMa")
CMv=GetVariable("CMv")
MMv=GetVariable("MMv")
AC=GetVariable("AC")
Continent=GetVariable("Continent")
IndoorsOutdoors=GetVariable("IndoorsOutdoors")

IndoorsOutdoors=GetVariable("IndoorsOutdoors")
IsFighting=GetVariable("IsFighting")
IsHungry=GetVariable("IsHungry")
IsRelaxing=GetVariable("IsRelaxing")
IsSleep=GetVariable("IsSleep")
IsStanding=GetVariable("IsStanding")
IsThirsty=GetVariable("IsThirsty")
Location=GetVariable("Location")
StoneSkin=GetVariable("StoneSkin")
Target=GetVariable("Target")
Trackie=GetVariable("Trackie")


if IndoorsOutdoors == "indoors" then
SetVariable("IndoorsOutdoors","Indoors")
IndoorsOutdoors ="Indoors"
else
SetVariable("IndoorsOutdoors","Outdoors")
IndoorsOutdoors ="Outdoors"
end--if


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

if StoneSkin == "Off" then
Send("|")
Send("cast 'stone skin'")
end--if

if IsThirsty == "Yes" then
Send("|")
Send("get barrel mass")
Send("drink barrel")
Send("cast 'create water' barrel")
end--if
</send>
  </trigger>
</triggers>



So far from what I see nothing is wrong.
[Go to top] top

Posted by Nick Gammon   Australia  (19,180 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Wed 19 Oct 2011 07:49 AM (UTC)  quote  ]
Message
So is this a question, or are you saying it is all working fine?

- Nick Gammon

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

Posted by Warbit   USA  (47 posts)  [Biography] bio
Date Reply #8 on Wed 19 Oct 2011 08:02 AM (UTC)  quote  ]

Amended on Wed 19 Oct 2011 08:19 AM (UTC) by Warbit

Message
No question, Well not with what I have. Right now I am trying to get the IsHungry to fire only once now.

I am monkeying with your wait.time function. Hoping that will fix it. Didn't expect such a quick response. So no question yet want to mess with it some more, before I ask. Thought the above was working perfectly until I got hungry.

Ok yes i do have question.

I think problem is that even thought I have trigger set to switch IsHungry from Yes to No. My script seems to me firing 3 or more times .

Here are all my Triggers
Mud tells me I am Hungry. So I made trigger Set Variable IsHungry to Yes.

<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="FoodandWater"
   match="*You are hungry.*"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable("IsHungry","Yes")
IsHungry = "Yes"</send>
  </trigger>
</triggers>


Prompt Sees IsHungry is Yes
So it
casts create food spell
gets food
and i eat food.
I added wait 21 seconds in hopes that it would give propmpt time to see that ISHungry is Now No. That will come from trigger after prompt trigger.

This is current Prompt trigger.

<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="Prompt"
   match="&lt;*/*Hp */*Ma */*Mv AC:* Continent:* Weather:*&gt;"
   send_to="12"
   sequence="100"
  >
  <send>

SetVariable("CHp","%1")
SetVariable("MHp","%2")
SetVariable("CMa","%3")
SetVariable("MMa","%4")
SetVariable("CMv","%5")
SetVariable("MMv","%6")
SetVariable("AC","%7")
SetVariable("Continent","%8")
SetVariable("IndoorsOutdoors","%9")


CHp=GetVariable("CHp")
MHp=GetVariable("MHp")
CMa=GetVariable("CMa")
MMa=GetVariable("MMa")
CMv=GetVariable("CMv")
MMv=GetVariable("MMv")
AC=GetVariable("AC")
Continent=GetVariable("Continent")
IndoorsOutdoors=GetVariable("IndoorsOutdoors")

IndoorsOutdoors=GetVariable("IndoorsOutdoors")
IsFighting=GetVariable("IsFighting")
IsHungry=GetVariable("IsHungry")
IsRelaxing=GetVariable("IsRelaxing")
IsSleep=GetVariable("IsSleep")
IsStanding=GetVariable("IsStanding")
IsThirsty=GetVariable("IsThirsty")
Location=GetVariable("Location")
StoneSkin=GetVariable("StoneSkin")
Target=GetVariable("Target")
Trackie=GetVariable("Trackie")


if IndoorsOutdoors == "indoors" then
SetVariable("IndoorsOutdoors","Indoors")
IndoorsOutdoors ="Indoors"
else
SetVariable("IndoorsOutdoors","Outdoors")
IndoorsOutdoors ="Outdoors"
end--if


if IsHungry == "Yes" then
require "wait"
wait.make (function ()
wait.time (21)
Send("|")
Send("cast 'create food'")
Send("get food")
Send("eat food")
end)
end--if

if StoneSkin == "Off" and CMa&gt;25  then
Send("|")
Send("cast 'stone skin'")
end--if

if IsThirsty == "Yes" then
require "wait"
wait.make (function ()
wait.time (21)
Send("|")
Send("get barrel mass")
Send("drink barrel")
Send("cast 'create water' barrel")
end)
end--if
</send>
  </trigger>
</triggers>


After I eat Mud tell me I am no longer hungry.
So I want to make IsHungry equal to No.
Here is No longer hungry trigger.

<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="FoodandWater"
   match="*You are no longer hungry.*"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable("IsHungry","No")
IsHungry=GetVariable("IsHungry")
IsHungry = "No"
</send>
  </trigger>
</triggers>


I have compare string to number error in prompt trigger but I will fix that later.


[Go to top] top

Posted by Warbit   USA  (47 posts)  [Biography] bio
Date Reply #9 on Wed 19 Oct 2011 08:26 AM (UTC)  quote  ]

Amended on Wed 19 Oct 2011 08:28 AM (UTC) by Warbit

Message
Sorry Physical Appearance of my prompt is.

<481/578Hp 97/104Ma 331/331Mv AC:-7.3 Continent:Vk Weather:overcast>



Send("|")

Sends command to mud to clear buffer of all previous commands.
[Go to top] top

Posted by Warbit   USA  (47 posts)  [Biography] bio
Date Reply #10 on Wed 19 Oct 2011 08:33 AM (UTC)  quote  ]
Message
I know easy way is to make trigger that fires on the words you are hungry. But I am mostly interested in learning to use variables.
[Go to top] top

Posted by Nick Gammon   Australia  (19,180 posts)  [Biography] bio   Forum Administrator
Date Reply #11 on Wed 19 Oct 2011 08:34 PM (UTC)  quote  ]
Message
I don't understand what you are doing here:


if IndoorsOutdoors == "indoors" then
  SetVariable("IndoorsOutdoors","Indoors")
  IndoorsOutdoors ="Indoors"
else
  SetVariable("IndoorsOutdoors","Outdoors")
  IndoorsOutdoors ="Outdoors"
end--if


You are setting two types of variables everywhere - MUSHclient variables, and Lua variables. How about deciding which one you want to use and stick with that? This is just making your code twice as long and twice as confusing.

See this, it explains the difference:

http://www.gammon.com.au/forum/?id=10863

- Nick Gammon

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

Posted by Nick Gammon   Australia  (19,180 posts)  [Biography] bio   Forum Administrator
Date Reply #12 on Thu 20 Oct 2011 12:29 AM (UTC)  quote  ]
Message
I got your trigger to match (fire) - providing there is nothing else on the line. If you have something after the prompt, you may want to put in a trailing asterisk.

- Nick Gammon

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

Posted by Warbit   USA  (47 posts)  [Biography] bio
Date Reply #13 on Thu 20 Oct 2011 06:58 AM (UTC)  quote  ]
Message
Thanks Nick re watched video and it was big help.
Then I added HpNeeded = MHp - CHp

kept getting expected '=' near HpNeeded

Went through script and it was a capital IF instead of small if

fixed that.

Then I got trying to do math with nil value. So tried the SetVariable(GetVariable isnumber)) thing you showed me in wholist counter minus or zero thing.

Didn't work. So I tried to convert my trigget to regular expression. Like you showed on one of your forumn pages when you was naming wildcards and and changing wildcards from stings to decimals.

Summary How do I convert this:

<578/578Hp 104/104Ma 331/331Mv AC:-4.3 Continent:Vk Weather:overcast>

So that the wildcards I get are

<(Digit wildcard)/(Digit wildcard)Hp (Digit wildcard)/(Digit wildcard)Ma (Digit wildcard)/(Digit wildcard)Mv AC:(Signed Decimal wildcard) Continent:* Weather:*>

Using Regualar Expression.

Question
1. What is correct syntax for regular expression of prompt above.
2. Looking for Link to your tutorial showing how to do so, also. For reference.

Here is my attempt and it doesn't do anything now unfortunately. If I figure it out before you answer I will delete this.


<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 MyHpNeeded &gt; 77 and CMa&gt; 77 then
Send("cast 'cure normal'")
end--if</send>
  </trigger>
</triggers>


Here is link I used trying to get it right.
http://www.gammon.com.au/forum/?id=5089

[Go to top] top

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

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

Message
Ok Found your example.
The link is Here.
http://www.gammon.com.au/forum/?id=6030

OK added + signs
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 MyHpNeeded &gt; 77 and CMa&gt; 77 then
Send("cast 'cure normal'")
end--if</send>
  </trigger>
</triggers>

[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.


3,590 views.

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

[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]