World.DoAfter problems

Posted by BlueEyes on Thu 20 Aug 2009 12:40 AM — 18 posts, 81,695 views.

#0
I've tried sending this to world, execute, script etc etc and still can not seem to get it work, what am I doing wrong?


<aliases>
  <alias
   match="lazy"
   enabled="y"
   sequence="100"
  >
  <send>pilot steer n
world.doafter 5, "pilot steer n"</send>
  </alias>
</aliases>
Amended on Thu 20 Aug 2009 01:02 AM by BlueEyes
USA #1
DoAfter is capitalized (like so).

EDIT: Actually, what scripting language are you using? That looks like VBscript.
Amended on Thu 20 Aug 2009 12:51 AM by Twisol
#2
I need it to be in lua so would it be

DoAfter 1, (pilot steer n)
USA #3
In Lua, it would be:

DoAfter(1, "pilot steer n")



Here's what I think you want:


<aliases>
  <alias
   match="lazy"
   enabled="y"
   sequence="100"
   send_to="12"
  >
    <send>
      Send("pilot steer n")
      DoAfter(5, "pilot steer n")
    </send>
  </alias>
</aliases>


Notice also that I put the plaintext command (the first line in your alias) in a Send() call, and added a send_to attribute which is the same thing as setting the Send To dropdown to Script.
Amended on Thu 20 Aug 2009 01:08 AM by Twisol
USA #4
line 1 is the raw text that you'd send to world.
line 2 is the script command to wrap it in a timer that you'd send to script.

do one or the other, not both. :)
#5
I believe

DoAfter(1, "pilot steer n")

is what you want in the field and don't forget to change the
Send to: world
into Send to: script
you will find this on the left towards the bottom.

That's what got me the first time.
#6
Alright I have this and it is working, now I need it to turn off and on ... how would I go about doing that?

USA #7
What do you mean 'turn on and off'? The alias? It will only run once for every time you use it.
#8
Alright I have a timer to send it when I have finished it which is 20 seconds now if I need to stop it while in progress how would I do that?
#9
Template:function=EnableAlias
EnableAlias

The documentation for the EnableAlias script function is available online. It is also in the MUSHclient help file.


Is this what your looking for?
#10
No idea... what I truly need is for this alias to continue to loop and when I need it off it disables the alias. Here is what I got so far.


<aliases> 
  <alias 
   match="lazy" 
   enabled="y" 
   send_to="12" 
   sequence="100" 
  > 
  <send> 
Send("pilot steer n") 
DoAfter(.5, "pilot steer n") 
DoAfter(1, "pilot steer n") 
DoAfter(1.5, "pilot steer n") 
DoAfter(2, "pilot steer n") 
DoAfter(2.5, "pilot steer w") 
DoAfter(3, "pilot steer w") 
DoAfter(3.5, "pilot steer w") 
DoAfter(4, "pilot steer w") 
DoAfter(4.5, "pilot steer w") 
DoAfter(5, "pilot steer s") 
DoAfter(5.5, "pilot steer s") 
DoAfter(6, "pilot steer s") 
DoAfter(6.5, "pilot steer s") 
DoAfter(7, "pilot steer s") 
DoAfter(7.5, "pilot steer e") 
DoAfter(8, "pilot steer e") 
DoAfter(8.5, "pilot steer e") 
DoAfter(9, "pilot steer e") 
DoAfter(9.5, "pilot steer e") 
</send> 
  </alias> 
</aliases>
#11
could I just make another quick alias that does

EnableAlias ("lazy", true)

and another that

DisableAlias ("lazy", true)
#12
That would work but the alias with the commands you want to send won't loop.

Make a timer that you enable or disable from an alias.
Amended on Thu 20 Aug 2009 03:31 AM by Blainer
#13
would that be EnableTimer ("lazy", true) and DisableTimer("lazy, true)

?
#14
Template:function=EnableTimer
EnableTimer

The documentation for the EnableTimer script function is available online. It is also in the MUSHclient help file.

#15
So to disable I would EnableAlias ("lazy", false)
#16
Correct. :)
Australia Forum Administrator #17
You still don't have a timer there. The thing called "lazy" is an alias, not a timer.

One approach would be to make a timer, that does "lazy" every 10 seconds.

I should point out too that to enable and disable the alias it has to have a name.

So far, "lazy" is what it matches on, not its name.

What I suggest is to give the timer a name, and make the timer call the alias. This is what I mean:


<aliases>
  <alias
   name="pilot_steer"
   match="do_pilot_steer_thing"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

directions = { "n", "w", "s", "e" }

require "wait"
wait.make (function ()

  for dir = 1, #directions do
    for i = 1, 5 do
      Send("pilot steer " .. directions [dir]) 
      wait.time (0.5)
    end  -- doing it 5 times
  end -- for each direction

end )

</send>
  </alias>

  <alias
   match="pilot start"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

if GetTimerInfo ("pilot_timer", 6) then
  Note "Pilot already started."
else
  EnableTimer ("pilot_timer", true)  -- start timer
  ResetTimer ("pilot_timer")  -- make sure back to zero
  Note "Starting pilot"
end -- if

</send>
  </alias>

  <alias
   match="pilot stop"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

if GetTimerInfo ("pilot_timer", 6) then  -- if enabled calculate time to go
  local time_to_go = os.difftime (GetTimerInfo ("pilot_timer", 12), os.time ())
  Note ("steering will stop in ", time_to_go, " seconds.")
else
  Note ("timer already disabled")
end -- if

EnableTimer ("pilot_timer", false)  -- disable timer

</send>
  </alias>
</aliases>


The above is 3 aliases:

  • do_pilot_steer_thing - which does the actual steering in a simple loop
  • pilot start - that starts the timer, so the steering does one sequence
  • pilot stop - that stops the timer, so the steering will finish at the end of the current sequence - I presume you want the ship to stop back at shore, or the whole thing will be out of whack. It checks the timer and tells you how many seconds it has to go.


Now you need the timer:


<timers>
  <timer name="pilot_timer" 
     second="11.00" 
     offset_second="10.00"    
     send_to="10"
>
  <send>do_pilot_steer_thing</send>

  </timer>
</timers>


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


That simply calls "do_pilot_steer_thing" every 11 seconds - and since it sends to "execute" the alias picks it up. The 11 seconds is to make sure the alias has a chance to finish before being called again. The offset of 10 seconds is so you don't have to wait 11 seconds when you first start the boat (you only wait 1 second).