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
➜ General
➜ Send looping
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Green
(6 posts) 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 < (maxhp / 2) ) then
InfoColour ("red")
end
Info ("HP: ", hp, "/", maxhp)
-- Step 2B: FTG monitor.
InfoColour ("lime")
if (stm < (maxstm / 2) ) then
InfoColour ("red")
end
Info (" Stm: ", stm, "/", maxstm)
-- Step 2C: Favor monitor
InfoColour ("lime")
if (favor < (maxfavor / 2) ) then
InfoColour ("red")
end
Info (" Favor: ", favor, "/", maxfavor)
if (hp < (maxhp / 2) ) then
-- Send ("lowHPZ") -- ***** loops from here?
ColourNote ("white", "blue", "LOW F@CKING HP!")
end
</send>
</trigger>
</triggers>
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) 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 | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) 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 | | Top |
|
| Posted by
| Green
(6 posts) Bio
|
| Date
| Reply #3 on Fri 25 May 2018 12:29 PM (UTC) |
| Message
| | ok thanks, i'll check it and see what happens :) | | Top |
|
| Posted by
| Green
(6 posts) 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 < (maxhp / 2) ) then
InfoColour ("red")
end
Info ("HP: ", hp, "/", maxhp)
-- Step 2B: FTG monitor.
InfoColour ("lime")
if (stm < (maxstm / 2) ) then
InfoColour ("red")
end
Info (" Stm: ", stm, "/", maxstm)
-- Step 2C: Favor monitor
InfoColour ("lime")
if (favor < (maxfavor / 2) ) then
InfoColour ("red")
end
Info (" Favor: ", favor, "/", maxfavor)
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
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
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) 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
|
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 | | 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.
20,742 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top