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 delay in a script with multiple commands
|
Trigger delay in a script with multiple commands
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Cnauir
(6 posts) Bio
|
| Date
| Thu 16 Jan 2020 12:46 PM (UTC) |
| Message
| Hi, i am completely new to scripts and i wanted to make a script delay before the trigger sends off multiple commands.
Reading the forum i have found out that i can make the trigger "send to script" and someone else posted the script line to make it have a random delay.
DoAfter(math.random(0.5),"daze attacker")
This works like a charm, however i cannot figure out how to add multiple commands to that line.
I want it to send 4-5 commands to the mud on the trigger after the random delay, so something like this?:
DoAfter(math.random(0.5),"daze attacker"/"knockdown attacker"/"kill attacker")
I simply cannot figure out how to make that work :P
Hope you can help me :) | | Top |
|
| Posted by
| Fiendish
USA (2,556 posts) Bio
Global Moderator |
| Date
| Reply #1 on Thu 16 Jan 2020 03:06 PM (UTC) Amended on Thu 16 Jan 2020 08:55 PM (UTC) by Fiendish
|
| Message
| First, math.random only accepts integers, so you can't give it 0.5 as input. If you want 0.1-0.5 you need to do 1-5 and then divide by 10.
The thread I found (https://www.gammon.com.au/forum/?id=4351&reply=1) suggests "daze attacker\\nknockdown attacker\\nkill attacker" or "daze attacker\nknockdown attacker\nkill attacker" depending on where you do it.
You can also replace DoAfter with DoAfterSpecial and have _that_ send to Execute (you control where DoAfterSpecial sends to) and then use your configured command stack character if you have that enabled (commonly a semicolon) .
Like
DoAfterSpecial(math.random(5)/10, "daze attacker;knockdown attacker;kill attacker", sendto.execute)
or more generically
local stack_char = GetAlphaOption("command_stack_character")
DoAfterSpecial(math.random(5)/10, "daze attacker"..stack_char.."knockdown attacker"..stack_char.."kill attacker", sendto.execute)
Or you can have it send to script and do
DoAfterSpecial(math.random(5)/10, 'Send("daze attacker");Send("knockdown attacker");Send("kill attacker")', sendto.script)
|
https://github.com/fiendish/aardwolfclientpackage | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #2 on Thu 16 Jan 2020 08:39 PM (UTC) Amended on Thu 16 Jan 2020 08:41 PM (UTC) by Nick Gammon
|
| Message
| The MUD uses newlines to separate commands, so just put newlines between them. Fiendish is right about the math.random function returning integers.
DoAfter (math.random(5)/10, "daze attacker\nknockdown attacker\nkill attacker")
I notice Fiendish actually suggested this, so now you have two such suggestions. :) |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #3 on Thu 16 Jan 2020 08:44 PM (UTC) Amended on Thu 16 Jan 2020 08:46 PM (UTC) by Nick Gammon
|
| Message
| If you want more randomness (that is, a random delay between each command) then see this thread:
http://www.gammon.com.au/forum/?id=4956
In particular, the example here:
http://www.gammon.com.au/forum/?id=4956&reply=2#reply2
For example:
<aliases>
<alias
match="test"
enabled="y"
send_to="12"
sequence="100"
>
<send>
require "wait"
wait.make (function ()
wait.time (math.random(5)/10)
Send ("daze attacker")
wait.time (math.random(5)/10)
Send ("knockdown attacker")
wait.time (math.random(5)/10)
Send ("kill attacker")
end)
</send>
</alias>
</aliases>
 |
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
|
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Cnauir
(6 posts) Bio
|
| Date
| Reply #4 on Fri 17 Jan 2020 12:55 AM (UTC) |
| Message
| Thanks guys!
Got it up and working now :)
I might have some more questions soon :P | | Top |
|
| Posted by
| Cnauir
(6 posts) Bio
|
| Date
| Reply #5 on Sat 18 Jan 2020 12:25 PM (UTC) |
| Message
| | Okay i have another question..or two | | Top |
|
| Posted by
| Cnauir
(6 posts) Bio
|
| Date
| Reply #6 on Sat 18 Jan 2020 01:14 PM (UTC) |
| Message
| | Weird, it did not send the whole post, just the top line. Will post it again later. | | Top |
|
| Posted by
| Fiendish
USA (2,556 posts) Bio
Global Moderator |
| Date
| Reply #7 on Sat 18 Jan 2020 07:54 PM (UTC) |
| Message
| | Put new unrelated question into another thread please. |
https://github.com/fiendish/aardwolfclientpackage | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #8 on Sun 19 Jan 2020 05:27 AM (UTC) |
| Message
|
Cnauir said:
Weird, it did not send the whole post, just the top line. Will post it again later.
I agree with Fiendish. However sometimes bad UTF8 characters in a post will cause it to be truncated. Save the post somewhere else (eg. Notepad) before sending, in case you need to examine it and re-post it. |
- 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.
29,118 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top