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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Send looping

Send looping

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


Posted by Green   (6 posts)  [Biography] bio
Date Thu 24 May 2018 08:27 PM (UTC)

Amended on Thu 24 May 2018 08:36 PM (UTC) by Green

Message
Trying to send an alias to the world when health is low...
i changed the send part so there are no other alis/trigs like it.. still spams / loops over and over.. when i comment out the send.. it works fine.


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="PROMPT"
   keep_evaluating="y"
   match="^H\: (.*?)\/(.*?) S\: (.*?)\/(.*?) Favors\: (.*?)\/(.*?)$"
   name="HPmon2"
   omit_from_output="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send> hp = %1
 maxhp=%2
 stm=%3
 maxstm=%4
 favor=%5
 maxfavor=%6
 

-- Step #2: Info bar.
-- Step #2A: Basic setup + HP monitor.
ShowInfoBar (Visible)
InfoClear ()
InfoBackground ("black")
InfoFont ("FixedSys", 9, 0)

InfoColour ("lime")
if (hp &lt; (maxhp / 2) ) then
  InfoColour ("red")  
end
Info ("HP: ", hp, "/", maxhp)

-- Step 2B: FTG monitor.
InfoColour ("lime")
if (stm &lt; (maxstm / 2) ) then
  InfoColour ("red")   
end
Info ("   Stm: ", stm, "/", maxstm)

-- Step 2C: Favor monitor
InfoColour ("lime")
if (favor &lt; (maxfavor / 2) ) then
  InfoColour ("red")  
end
Info ("   Favor: ", favor, "/", maxfavor)

if (hp &lt; (maxhp / 2) ) then  
   -- Send ("lowHPZ")  -- ***** loops from here?
ColourNote ("white", "blue", "LOW F@CKING HP!")

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

[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Fri 25 May 2018 01:17 AM (UTC)
Message
Probably your send is causing another status line to appear, so you notice your HP are low and you do another send, and get another status line, and so on.

You want some sort of test to only send (say) every 30 seconds.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Fri 25 May 2018 02:51 AM (UTC)
Message
For example:


if hp < (maxhp / 2)  then  
  if last_time_sent == nil or os.time () - last_time_sent > 20 then
    last_time_sent = os.time ()  -- remember when we sent
    Send ("lowHPZ")   -- send the command
    ColourNote ("white", "blue", "LOW F@CKING HP!")
    end -- if 20 seconds have passed
end  -- if low HP

- Nick Gammon

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

Posted by Green   (6 posts)  [Biography] bio
Date Reply #3 on Fri 25 May 2018 12:29 PM (UTC)
Message
ok thanks, i'll check it and see what happens :)
[Go to top] top

Posted by Green   (6 posts)  [Biography] bio
Date Reply #4 on Fri 25 May 2018 01:26 PM (UTC)

Amended on Fri 25 May 2018 02:15 PM (UTC) by Green

Message
so...
i tried your mod, and it stopped the looping ty!
a player said to use Execute ...to send an alias, instead of send, and it works good :)

here is the hp prompt trigger

<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="PROMPT"
   keep_evaluating="y"
   match="^H\: (.*?)\/(.*?) S\: (.*?)\/(.*?) Favors\: (.*?)\/(.*?)$"
   name="HPmon2"
   omit_from_output="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send> hp = %1
 maxhp=%2
 stm=%3
 maxstm=%4
 favor=%5
 maxfavor=%6
 

-- Step #2: Info bar.
-- Step #2A: Basic setup + HP monitor.
ShowInfoBar (Visible)
InfoClear ()
InfoBackground ("black")
InfoFont ("FixedSys", 9, 0)

InfoColour ("lime")
if (hp &lt; (maxhp / 2) ) then
  InfoColour ("red")  
end
Info ("HP: ", hp, "/", maxhp)

-- Step 2B: FTG monitor.
InfoColour ("lime")
if (stm &lt; (maxstm / 2) ) then
  InfoColour ("red")   
end
Info ("   Stm: ", stm, "/", maxstm)

-- Step 2C: Favor monitor
InfoColour ("lime")
if (favor &lt; (maxfavor / 2) ) then
  InfoColour ("red")  
end
Info ("   Favor: ", favor, "/", maxfavor)

if (hp &lt; (maxhp / 2)  ) then  
  if (last_time_sent == nil or os.time () - last_time_sent &gt; 20) then
    last_time_sent = os.time ()  -- remember when we sent
    Execute ("lowHP")   -- send the command
    ColourNote ("white", "blue", "LOW FeCKING HP!")
    end -- if 20 seconds have passed
end  -- if low HP
</send>
  </trigger>
</triggers>




also, as a side note...
i tried to use a toggle instead of checking the time, but
couldn't get it to work... if a variable is not there, it should be auto created?



if (hp < (maxhp / 2) and tonumber(GetVariable("hpTOG")) == 0 ) then  
    Execute ("lowHP") 
    SetVariable ("hpTOG", 1)
ColourNote ("white", "blue", "LOW FeCKING HP!")

end
if (hp == maxhp  and tonumber(GetVariable("hpTOG")) == 1 ) then  
   
    SetVariable ("hpTOG", 0)
ColourNote ("white", "blue", "Healed!")

end
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Fri 25 May 2018 08:13 PM (UTC)

Amended on Sat 26 May 2018 05:26 AM (UTC) by Nick Gammon

Message
Template:function=GetVariable GetVariable

The documentation for the GetVariable script function is available online. It is also in the MUSHclient help file.



If GetVariable is called for a variable that doesn't exist, it returns nil in Lua. This is because any other value (eg. zero) could be a valid value to store in a variable.

You don't have to use client variables anyway for simple things like toggles, because they don't need to be stored for next time.

In my example code:


if last_time_sent == nil ...


That first tests if last_time_sent is nil (which means that variable wasn't created yet).

In your code:


tonumber(GetVariable("hpTOG"))


The function tonumber returns nil if passed nil, so you could have tested for that. eg.


hpTOG = tonumber (GetVariable("hpTOG"))

if hp < (maxhp / 2) and 
  (hpTOG == nil or hpTOG == 0) then
...

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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.


13,579 views.

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

Go to topic:           Search the forum


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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at HostDash]