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.
Entire forum
➜ MUSHclient
➜ General
➜ World.DoAfter problems
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1
2
Posted by
| BlueEyes
(28 posts) Bio
|
Date
| Reply #15 on Thu 20 Aug 2009 04:22 AM (UTC) |
Message
| So to disable I would EnableAlias ("lazy", false) | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #17 on Thu 20 Aug 2009 05:49 AM (UTC) Amended on Thu 20 Aug 2009 05:58 AM (UTC) by Nick Gammon
|
Message
| 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>
|
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).
|
- 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.
57,175 views.
This is page 2, subject is 2 pages long:
1
2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top