execute in script with delay

Posted by Gronka on Thu 02 Aug 2018 12:44 PM — 2 posts, 12,729 views.

#0
Mushclient version 5.06-pre
Lua scripting language

I am trying to fire a script off a trigger.
The intention is to get an execute command sent after the trigger event happens. A delay of a couple seconds works. HEck even .5 seconds would do the trick.

I complete the quest!
trigger event now
script delay
execute xcp

I have tried a few things and this is the latest after researching the forums.

I also added a second to world command of 'cheer' just for giggles and to make sure there is a delay since I don't know how to delay an execute. Here is my trigger:

<triggers>
<trigger
enabled="y"
match="You have completed your quest."
send_to="12"
sequence="100"
>
<send>world.DoAfter 2, "cheer" world
world.execute xcp</send>
</trigger>
</triggers>


Here is my error:
Compile error
World: redacted
Immediate execution
[string "Trigger: "]:1: '=' expected near '2'
Australia Forum Administrator #1
Functions in Lua require their arguments to be in brackets, with a minor exception of taking a single string argument, eg.


print "hello"


You don't need to use "world", so your first line should look like:


DoAfter (2, "cheer")


See here for how to introduce delays into a script:

http://www.gammon.com.au/forum/?id=4956

Also the "wait" module mentioned here:

http://www.gammon.com.au/modules

For example:


require "wait"

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

 
  Send ("foo")

  wait.time (1)  -- wait a second

  Send ("bar")

end)  -- end of coroutine





Lua is case-sensitive so the "execute" call should be:



Execute ("xcp")