making a line in a trigger wait a sec or 2

Posted by Sprockfizzly on Fri 16 Feb 2018 12:41 AM — 7 posts, 28,456 views.

#0
i play this mud that has a command buffer on body location commands, and im trying to have a trigger do a spell, but i cant get it to wait long enough for the item i drop to disappear before targeting the one in my inventory. i tried world.doafter, and DoAfter. but they both say unrecognized command. this is the first trigger thats not working. its a chain of 3, if i do stuff manually i can get the other 2 to fire off with no problem.


<triggers>
  <trigger
   enabled="y"
   ignore_case="y"
   match="You drop *(a|an|the) *(bronze|iron|steel) shortsword in the void."
   regexp="y"
   sequence="100"
  >
  <send>fab short
tar short
rw
rw
rp
</send>
  </trigger>
</triggers>


[EDIT] Put trigger into code tags.
Amended on Sun 18 Feb 2018 02:39 AM by Nick Gammon
USA #1
Sounds to me like what you want is a timer. Here's how I would code it, though I use Lua, so your exact coding will be different. I'm not sure which command it is you want to execute later, so I'm going to assume that tar short is what you want to go with.

<muclient>
<triggers>
    <trigger enabled="y" ignore_case="y" match="You drop *(a|an|the) *(bronze|iron|steel) shortsword in the void."
regexp="y" send_to="12" sequence="100">
        <send>fabTar()</send>
    </trigger>
</triggers>

<script>
<![CDATA[

function fabTar()
    Send("fab short")
    AddTimer("fabTar", 0, 0, 3, "fabTar2()", timer_flag.Enabled + timer_flag.OneShot)
    SetTimerOption("fabTar", "send_to", 12)
end

function fabTar2()
    Send("tar short")
    Send("rw")
    Send("rw")
    Send("rp")
end

]]>
</script>
</muclient>
Amended on Fri 16 Feb 2018 11:53 PM by Areadien
USA Global Moderator #2
Quote:
i tried world.doafter, and DoAfter. but they both say unrecognized command


It looks like the reason for the problem that you're encountering is that your trigger is sending directly to the game, and not passing your <send></send> section to the script interpreter.

Set your trigger to send to Script instead of the default to World and then wrap everything in Send() functions, like so...


<triggers>
<trigger
enabled="y"
ignore_case="y"
match="You drop *(a|an|the) *(bronze|iron|steel) shortsword in the void."
regexp="y"
sequence="100"
send_to="12"
>
<send>
Send("fab short")
Send("tar short")
Send("rw")
Send("rw")
Send("rp")
</send>
</trigger>
</triggers>


http://www.gammon.com.au/scripts/function.php?name=Send
Amended on Fri 16 Feb 2018 04:17 PM by Fiendish
Australia Forum Administrator #3
That doesn't address the issue of the delay. Try reading this:

http://www.gammon.com.au/forum/?id=4956
Australia Forum Administrator #4
Also see: http://www.gammon.com.au/modules

Scroll down to the part about "wait.lua".
#5
Thanks for the replys! Internets been down so i havent been able to try anything. I have read the posts Mr. Gammon suggested but dont know anything about lua so i somewhat skimmed over it. But i guess i will be reading up on it now :)

Areadien, that was the command i wanted delayed. If my internet ever gets fixed i will try your suggestion.

Thanks all. Will post again when i can!
Australia Forum Administrator #6
This is the general idea:


<triggers>
  <trigger
   enabled="y"
   ignore_case="y"
   match="^You drop +(a|an|the) +(bronze|iron|steel) shortsword in the void\.$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>

require "wait"

wait.make (function ()  --- coroutine below here

  Send ("fab short")
  wait.time (2)   -- wait 2 seconds
  Send ("tar short")
  Send ("rw")
  Send ("rw")
  Send ("rp")

end)  -- end of coroutine

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


Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


This sends "fab short", waits 2 seconds, and then sends the other stuff. You could add in other waits if you wanted to.