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
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Jacob_P
(9 posts) Bio
|
Date
| Wed 24 Nov 2010 11:35 AM (UTC) |
Message
| Im a new on using Mushclient and I like it alot. I have an irritating problem tho.
How do I create a trigger that fires after 2-5 secs randomly ?
I know I have to make a script for it but I have no idea what it shall look like and how to link it to a trigger.
I have a simple pattern I want it to trigger on, eg. " (playername) is hurt"
I then want the trigger to send "heal (playername)" to world, preferably at a random time from 2-5 seconds !
I hope someone can help me out with this !
Regards
Jakob | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #1 on Wed 24 Nov 2010 05:01 PM (UTC) |
Message
| DoAfter(math.random(4)+1, "heal %1")
|
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Jacob_P
(9 posts) Bio
|
Date
| Reply #2 on Thu 25 Nov 2010 06:50 AM (UTC) |
Message
| Okay, thanks ! But how do I implement this into my trigger ? | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #3 on Thu 25 Nov 2010 06:53 AM (UTC) |
Message
| Well, it's a script call, so first you need to make sure the trigger is set to Send to Script. Now lets look at the problem you have: You want a trigger that delays its action, right? So you use a script function that does stuff later. That's what DoAfter does: it takes an amount of time (in seconds), and something to send. Behind the scenes, it creates a temporary timer (which you can look at in the timers list if you're fast enough).
In other words, just paste what I gave you into the send box, and make sure you're sending to script. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Jacob_P
(9 posts) Bio
|
Date
| Reply #4 on Thu 25 Nov 2010 09:34 AM (UTC) |
Message
| Okay!
So I will simply create a empty script named whatever I want and let the trigger send that piece of code to the script that executes it? | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #5 on Thu 25 Nov 2010 09:39 AM (UTC) |
Message
| I didn't understand that at all. ^_^ Give it a try and if it doesn't work, paste what you have for us to dissect. It's always easier to work with the code directly. :)
 |
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.
|
|
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Jacob_P
(9 posts) Bio
|
Date
| Reply #6 on Thu 25 Nov 2010 11:09 AM (UTC) |
Message
| Im confused :p
, I have nothing to share :-) thats why I wrote here! I have no script and no trigger! I know how to create a trigger, thats simple, but I dont know how to create the script itself and make the trigger run the script when the MUD says "you are hurt" ! | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #7 on Thu 25 Nov 2010 11:24 AM (UTC) Amended on Thu 25 Nov 2010 11:25 AM (UTC) by Twisol
|
Message
|
Jacob_P said: Im confused :p
, I have nothing to share :-) thats why I wrote here! I have no script and no trigger!
I know, I was hoping you might be able to try it yourself after my help before, and maybe come back with some more insight into the problem even if you didn't succeed. But no matter. :)
Jacob_P said: I know how to create a trigger, thats simple, but I dont know how to create the script itself and make the trigger run the script when the MUD says "you are hurt" !
That's the easy part. Do you see the big text box in the trigger editing dialog? It says "Send:" to the left. Just paste the script above into that. Now do you see right below that, a dropdown box with "Send to:" to the left? Click it and select "Script".
What I think you're getting confused by is the "Script" field further down in the dialog. I'm not talking about that. It's useful, but not terribly different. The major difference is that you would put the name of a function to call in that field, and create the function somewhere else (likely in your script file). But again, this is not what I'm asking you to do. :) |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Jacob_P
(9 posts) Bio
|
Date
| Reply #8 on Thu 25 Nov 2010 03:42 PM (UTC) |
Message
| Yeah, thats what I tried but it aint working at all ! | Top |
|
Posted by
| Jacob_P
(9 posts) Bio
|
Date
| Reply #9 on Thu 25 Nov 2010 03:47 PM (UTC) |
Message
|
Jacob_P said:
Yeah, thats what I tried but it aint working at all !
I take that back :D
Its working, thanks for the help, i think im getting the hang of it ! | Top |
|
Posted by
| Giddeon
(3 posts) Bio
|
Date
| Reply #10 on Tue 14 Dec 2010 10:24 PM (UTC) |
Message
| Hey guys. I had the same question Jacob did and exactly his questions and level of understanding and the good replies here got me squared away. Many thanks!
FWIW, I might have figured out the "Send to" dropdown if the option was "Script Engine" instead of "Script". Just seeind script there made me think the contents of that big text area would be passed a a script that you needed to specify in that "Script" field below.
I'd like to put a little note somewhere in there telling me what that script's supposed to do. I suppose the best way to do that is in the scripting lang itself? Use whatever comment mechanism it provides?
Which scripting language is this in anyway? Is that a line of LUA?
| Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #11 on Tue 14 Dec 2010 11:12 PM (UTC) |
Message
|
Giddeon said:
I'd like to put a little note somewhere in there telling me what that script's supposed to do. I suppose the best way to do that is in the scripting lang itself? Use whatever comment mechanism it provides?
Which scripting language is this in anyway? Is that a line of LUA?
Yes, it's Lua - the recommended script language. (Lua not LUA).
I would use comments to explain what you are doing - I usually comment heavily because you never know when you will next pick up something and wonder what the heck you were doing. In Lua single-line comments are introduced with two hyphens, eg.
And multiple-line comments with two hyphens and two brackets, eg.
--[[
this is a multi-line comment
and so is this
--]]
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Giddeon
(3 posts) Bio
|
Date
| Reply #12 on Wed 15 Dec 2010 07:58 PM (UTC) |
Message
| I've never seen those characters used for commenting. I've just skimmed a bit of Lua's history from Wikipedia.
Looks like I'll get to do a little mudding and add another language to the resume all at the same time!
Wonder if I can work a tax exemption in there somehow...
Thanks a ton Nick. I'm loving this client. | 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.
41,682 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top