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/script execution order mixup?
Trigger/script execution order mixup?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Sun 09 May 2004 06:37 PM (UTC) Amended on Sun 09 May 2004 06:43 PM (UTC) by Ked
|
Message
| In trying to make a small setup for channeling chat out of my output window and into a notepad one I stumbled upon something that surprised me - I use a prompt trigger with a sequence of 0 to disable a * trigger with a sequence of 1, and both triggers call the same script sub. It seems that this script is called only after all triggers have matched on a line, so the sequence 1 trigger is disabled already after it matches, even though it is being disabled by a trigger with sequence 0. Here's the actual setup:
<triggers>
<trigger
keep_evaluating="y"
match="^[0-9]+h, [0-9]+m \D*?-.*$"
name="chat_end"
regexp="y"
script="ChannelChat"
>
</trigger>
<trigger
match="^(.*)$"
name="chat_middle"
omit_from_output="y"
regexp="y"
script="ChannelChat"
sequence="1"
>
</trigger>
<trigger
enabled="y"
lines_to_match="2"
match="^(?:[0-9]+h, [0-9]+m \D*?-|)([A-Z][a-z]+? (?:say|says), ".*)$"
name="chat_start"
omit_from_output="y"
regexp="y"
script="ChannelChat"
sequence="100"
>
</trigger>
</triggers>
And the script:
sub ChannelChat(name, output, wildcs)
select case name
case "chat_start"
world.AppendToNotepad "Chat", wildcs(1) & vbCRLF
world.EnableTrigger "chat_middle", 1
world.EnableTrigger "chat_end", 1
case "chat_middle"
world.AppendToNotepad "Chat", wildcs(1) & vbCRLF
case "chat_end"
world.AppendToNotepad "Chat", vbCRLF
world.EnableTrigger "chat_middle", 0
world.EnableTrigger "chat_end", 0
end select
end sub
The problem goes away if the prompt trigger sends its portion of the job to scripting, instead of calling the sub directly. This seems odd and I don't think it worked that way previously, though I might be wrong. In any case - the problem isn't major or immediate in this particular case, just wanted to clarify what is happening. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Mon 10 May 2004 07:13 AM (UTC) |
Message
| Triggers that call a sub have the sub calls queued, whereas "send to script" does it immediately. This was really done so that "omit from output" can omit the lines, and then the trigger scripts run, so that the world.note will add after the output is omitted. Also, if a trigger fires more than once on a line, the script is only called once.
Thus it would not surprise me if "send to script" ran before script subroutines. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #2 on Mon 10 May 2004 12:10 PM (UTC) |
Message
| So that is expected then? Okay. I guess it's not too much of a problem, since I can always just send to scripting as a workaround, and maybe use 2 triggers for the same line if I want to both omit the line from output and execute a script on it. | Top |
|
Posted by
| Shadowfyr
USA (1,790 posts) Bio
|
Date
| Reply #3 on Mon 10 May 2004 07:27 PM (UTC) Amended on Mon 10 May 2004 07:30 PM (UTC) by Shadowfyr
|
Message
| Hmm.. Interesting Nick. So a person could make one low numbered trigger using 'send to script' to read in the information for a line, then a second to omit it, but if you try to use a script to handle reading in the line before omitting it, it would fail, since it will have cleared the line before it is able to retrieve the styles and other information?
Not exactly consistent behaviour, but knowing that it behaves in such a manner, instead of more logically executing each trigger event as they happen, before testing against higher sequenced triggers is helpful. Knowing this you can trick the client into doing some things that are impossible otherwise, but it does introduce some interesting complications when you are not aware of it. In fact, for the above situation, you could have 'send to script' merely call a sub directly:
<send>call StoreLineInfo(getlinesinbuffer)</send>
so that the line you need is available for use when the omit trigger hits and calls its own sub to replace the original with a new one. Very interesting... | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #4 on Mon 10 May 2004 09:59 PM (UTC) |
Message
| Ah yes, true.
This behaviour is why you cannot do world.Note in "send to script" in triggers that omit from output. The way it works is to omit from output from the start of the line that did the triggering, and if your notes happen to be on the end of that they get omitted too.
Thus, the sequence is, if a trigger matches:
- Play trigger sound if wanted.
- Do "send" stuff. Note that "send to output window" is actually queued into a string for later appending to the output window. However "send to script (or world etc.)" will be executed right now.
- Do any line colouring requested (ie. change triggered line colour).
- Queue up the name of the trigger script (if any).
- Log the trigger if wanted.
- Omit from the first trigger line to end of output buffer (if multiple-lines, eg. soft line breaks).
- Append any "send to output window" text saved in the earlier step to the output window in the current note colour.
- Execute trigger scripts queued up earlier.
|
- 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.
15,849 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top