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 ➜ General ➜ Trigger seems to be sending too late

Trigger seems to be sending too late

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


Posted by Happyhellodude   (9 posts)  Bio
Date Sun 21 Jun 2009 12:36 PM (UTC)
Message
Ok my script will use SendImmediate to send "sip health" but then it won't follow the command untill the next prompt pops up and then the lines go out of where they usually go
this is a copy of my test run:

1658h, 2600m, 9650e, 11900w ex- <--Trigger fired first time
sip health <-- This is the command that is sent
The cultist draws his bone-handled knife from under his robes and stabs you.
1604h, 2600m, 9650e, 11900w ex-You take a drink from an ebony vial. <--the sip health command finally executed
sip health <-- script re-fires because it thinks low health
The elixir heals and soothes you. <-- cansiphealthmana = 0
1900h, 2600m, 9650e, 11900w ex-You take a drink from an ebony vial.
The elixir flows down your throat without effect.

This is the Lua script that is being run:

<triggers>
<trigger
enabled="y"
group="Healing"
match="*h, *m, *e, *w *"
send_to="12"
sequence="100"
>
<send>local current_health
local current_mana
local max_health
local max_mana
local cansiphealthmana
cansiphealthmana = tonumber(GetVariable("cansiphealthmana"))
current_health = tonumber("%1")
current_mana = tonumber("%2")
max_health = tonumber(GetVariable("max_health"))
max_mana = tonumber(GetVariable("max_mana"))
health_level = max_health*0.8
mana_level = max_mana*0.8
if cansiphealthmana == 1 then
if current_health &lt; health_level then
SendImmediate ("sip health")
elseif current_mana &lt; mana_level then
SendImmediate ("sip mana")
end
end
</send>
</trigger>
</triggers>

Also, Do I have to local all the variables at the start?

Thanks again people of the MUSHclient forum sorry about the mess
Top

Posted by Larkin   (278 posts)  Bio
Date Reply #1 on Sun 21 Jun 2009 01:06 PM (UTC)
Message
Where do you set cansiphealthmana to 0 or 1? Is that working correctly for you?

You can use the Trace option on the Game menu to see what's firing and executing, if triggers and/or aliases are the problem. You'll want to use print or Note to show current values for more debugging, however.
Top

Posted by Happyhellodude   (9 posts)  Bio
Date Reply #2 on Sun 21 Jun 2009 02:12 PM (UTC)
Message
These are the things that involve setting "cansiphealthmana"

<triggers>
<trigger
custom_colour="17"
enabled="y"
group="Healing"
match="Your mind feels stronger and more alert."
send_to="12"
sequence="100"
other_text_colour="red"
other_back_colour="lime"
>
<send>SetVariable ("cansiphealthmana", "0")</send>
</trigger>
<trigger
custom_colour="17"
enabled="y"
group="Healing"
match="You may drink another health or mana elixir."
send_to="12"
sequence="100"
other_text_colour="red"
other_back_colour="lime"
>
<send>SetVariable ("cansiphealthmana", "1")</send>
</trigger>
<trigger
enabled="y"
group="Healing"
match="The elixir heals and soothes you."
send_to="12"
sequence="100"
>
<send>SetVariable ("cansiphealthmana", "0")</send>
</trigger>
</triggers>


With trace on it seems to work heres is a bit of output:

This output I thought would show problems with my trigger or script because it is actually sending "sip health" too late:

1657h, 2600m, 9646e, 11900w ex- <-- Should have fired
You choke as you inhale water.
980h, 2600m, 9646e, 11900w ex- <-- Could have fired here
You may drink another health or mana elixir.
980h, 2600m, 9650e, 11900w ex- <-- Or here
<-- I sent the "up" command to the MUD
sip health <-- Now it sends "sip health"
up <-- And "up"
You take a drink from an ebony vial.
The elixir heals and soothes you.
1434h, 2600m, 9650e, 11900w ex-A deep pond. <-- Line in wrong place.

But this I can't figure out what is wrong:

1871h, 2600m, 9648e, 11900w ex-
TRACE: Matched trigger "*h, *m, *e, *w *"
You choke as you inhale water.
1194h, 2600m, 9648e, 11900w ex- <-- Trigger should have sent "sip health"
TRACE: Matched trigger "*h, *m, *e, *w *"
<-- There is a little wait here untill somthing happens
<-- POINT A
sip health <-- "sip health" is sent although it is before the "you choke as you inhale water" it seems as though it is sent because of it.
You choke as you inhale water. <--This is that somthing
624h, 2600m, 9650e, 11900w ex-You take a drink from an ebony vial. <-- Line in wrong place
TRACE: Matched trigger "*h, *m, *e, *w *"
sip health <-- "sip health" is sent again
The elixir heals and soothes you.
TRACE: Matched trigger "The elixir heals and soothes you."
978h, 2600m, 9650e, 11900w ex-You take a drink from an ebony vial.
TRACE: Matched trigger "*h, *m, *e, *w *"
The elixir flows down your throat without effect.
<-- POINT B
978h, 2600m, 9650e, 11900w ex-
TRACE: Matched trigger "*h, *m, *e, *w *"

Evrything between POINT A and POINT B happens very fast.

Sorry about the mess Again
Top

Posted by Happyhellodude   (9 posts)  Bio
Date Reply #3 on Sun 21 Jun 2009 02:16 PM (UTC)
Message
Sorry about this couldn't find any Edit button
Ignore the line that says
"With trace on it seems to work heres is a bit of output:"
Top

Posted by Larkin   (278 posts)  Bio
Date Reply #4 on Sun 21 Jun 2009 06:52 PM (UTC)
Message
This sort of thing is a common problem. Typically, if you set your balance variables only using triggers, you'll see occasional repeats when the trigger fires a couple of times before the action actually goes through.

It's better to set your cansiphealth to 0.5 when you send the 'sip health' command. Set a failsafe timer for a second or two that looks for cansiphealth == 0.5 and sets it back to 1. Your triggers that currently set it to 0 will only set it to 0 if it's currently 0.5 (little anti-illusion trick).

All problems solved?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #5 on Sun 21 Jun 2009 09:12 PM (UTC)
Message
Quote:

This output I thought would show problems with my trigger or script because it is actually sending "sip health" too late:


For one thing, in a client-server situation like a MUD, the next line from the server is not necessarily something in response to what you just sent - a fight message, or a chat message intervening it quite possible.

Second, the stuff about "it fired after the second prompt" is a known issue, see: http://mushclient.com/faq point 11.

Quote:

Do I have to local all the variables at the start?


You don't have to, local variables behave subtly differently from global ones. Usually the difference doesn't matter a heap. Effectively, local variables only exist beyond the point at which they are declared, and are invisible to other scripts (especially if you do "send to script") because those scripts are recompiled each time.

However global variables (ones without "local" in front of them) are placed in a "global variables" table, and are visible to every script in the client (in the same world, or the same plugin, at least).

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #6 on Sun 21 Jun 2009 09:15 PM (UTC)
Message
I agree with Larkin that you need to protect yourself against the same prompt happening in quick succession. Until the "sip elixir" is processed by the MUD, you may get the same prompt a few times, making it look like you need to sip again. What I would do is set a flag (like elixir_sipped = true) and then do not sip again while that flag is set. Meanwhile, when you get a message that indicates you have actually sipped it, set the flag to be false again, ready for next time.

- Nick Gammon

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

Posted by Happyhellodude   (9 posts)  Bio
Date Reply #7 on Mon 22 Jun 2009 03:09 AM (UTC)
Message
Ok, idid a little test by just pushing enter a few time and got a whole heap of prompts on no new lines:

2150h, 2600m, 9650e, 11900w ex-2150h, 2600m, 9650e, 11900w ex-2150h, 2600m, 9650e, 11900w ex-2150h, 2600m, 9650e, 11900w ex-2150h, 2600m, 9650e, 11900w ex-2150h, 2600m, 9650e, 11900w ex-2150h, 2600m, 9650e, 11900w ex-2150h, 2600m, 9650e, 11900w ex-

So I hunted around the output box and put a nice little tick in the "Convert IAC EOR/GA to newline so now I get: some nice new lines happening.
2150h, 2600m, 9650e, 11900w ex-
2150h, 2600m, 9650e, 11900w ex-
2150h, 2600m, 9650e, 11900w ex-

Now I then tested my triggers a walla they work perfectly without even needing the "health_sipped = true" part although I think I might leaveit in just to be sure.

I am playing on Achaea so if anybody else had these problems that may be why.

Thank you to Larkin and Nick Gammon for the speedy replys.
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.


26,714 views.

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.