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
➜ VBscript
➜ Multi-lined, variable trigger with delay and sound (Ahh!)
|
Multi-lined, variable trigger with delay and sound (Ahh!)
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Stenaglia
(3 posts) Bio
|
| Date
| Sat 21 Jan 2006 11:09 PM (UTC) |
| Message
| I have very little coding experience, so I decided to make this monster to help guide me on smaller projects. I'm sorry if it's long and tedious, but who knows, you all are most likely coders so you probably like this stuff.
Note: all my example codes are most likely in C or C++, since that's what I have coded in. I realize they're most likely totaly wrong since its the wrong language, but I hope you understand what I mean to say when I say it.
Alright, the question.
Firstoff, the trigger is two lines and includes a variable. Lets call the first line, which is constant, "blah" and the second "whatever x", x being the variable. There is more text after the variable, but I want the trigger to just ignore it for simplicity, so it would end with * most likely. So the output to trigger off of would be:
blah
whatever x
Based off of the variable, there would be separate outputs, most likely looking something like:
If x=(1,2,3) return "decline"
or x=(4,5,6) return string
with the string being out, e, ww, rr, (2 second delay)mg, (2 more seconds(4 total))df, (2 more seconds(6 total))job change, w, house, accept. These are all inputs, by the way.
Everything after "job change" I would assume would need the same delay as it so they would fire immediately after it.
I'd also like it to play a sound immediately after the output trigger, which I would assume would be something like
play sound (file location)
I would also like to know how to impliment this into mushclient. I assume I would save it in notepad and set that as the filelocation under the scripts tab of worldproperties, but I have a feeling there's more to it than that so any help with that would be appreciated.
Alright, I think that's everything. I hope all that made sense, and if it didn't I'd be glad to clerify. And thank you to anyone who gives this a shot. | | Top |
|
| Posted by
| Stenaglia
(3 posts) Bio
|
| Date
| Reply #1 on Sun 22 Jan 2006 07:17 PM (UTC) |
| Message
| I've been doing a lot of searching and I think I have a basic understanding of how to do this. First off though I need to specify some of my examples.
My output trigger would be, instead of
Blah
Whatever x
You wager 'crystalsword'
Impresario says, 'You will be wagering a Crystal Sword for a Assassin, do you
accept?'
"Assassin" is the variable I marked as x before, and the "do you accept?" is the constant that will be ignored, since it's irrelevant.
Depending upon what list the variable is in there will be a separate input. So, lets see my alpha script. And please, be patient.
<triggers>
<trigger
enabled="y"
match="^You wager/, 'crystalsword'/n.Impresario says/, 'You will be wagering a Crystal Sword for a %1*
multi_line="y"
send_to="2"
sequence="100"
>
<send>Match: %1
if %1=("Assassin" or ""Diamond Helmet" or "Pearl Lance") then
world.Send "decline"
if %1=("Genji Armor" or "Tiger Fangs" or "Flame Shield") then
PlaySound C:/blah
world.Send "out"
world.Send "e"
world.Send "ww"
world.DoAfter 1, "rr"
world.DoAfter 3, "mg"
world.DoAfter 5, "df"
world.DoAfter 7, "adark"
world.DoAfter 9, "job change soldier"
world.DoAfter 9, "seq2"
world.DoAfter 9, "w"
world.DoAfter 9, "wagerroom"
world.DoAfter 9, "say I accept"
world.DoAfter 9, "c"
</send>
</trigger>
</triggers> | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #2 on Sun 22 Jan 2006 11:05 PM (UTC) |
| Message
|
Quote:
match="^You wager/, 'crystalsword'/n.Impresario says/, 'You will be wagering a Crystal Sword for a %1*
I don't understand this bit. For a start, there is no closing quote, and second, the use of %1 is normally for the send text, not the match text. Do you mean a variable, like:
match="^You wager/, 'crystalsword'/n.Impresario says/, 'You will be wagering a Crystal Sword for a @assassin"
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Stenaglia
(3 posts) Bio
|
| Date
| Reply #3 on Sun 22 Jan 2006 11:54 PM (UTC) |
| Message
| Sorry about the closing quote, that was just me being careless it seems. But I do need to know how to set up a case variable. I've been searching around and how exactly to define a variable hasnt been very clear. What I need is to have two sets of items based on the variable, as in
if (variable)=(a,b,c,d) return this set of inputs, but if (variable)=(e,f,g,h) return this separete set of inputs. The letters here stand for a set such that if the variable is one of the items in one particular set, it choses the input that that set returns. If anyone can explain this to me it would be greatly appreciated.
Secondly, I'm curious as to why you omited the wild card at the end if the match. Since there is more text on that line, I would have assumed you needed to put a certain wildcard to indicate that there is text after this point, but it will be ignored and is irrelevant.
Thanks again for taking the time to look at this and try to help out. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #4 on Mon 23 Jan 2006 01:23 AM (UTC) Amended on Mon 23 Jan 2006 01:24 AM (UTC) by Nick Gammon
|
| Message
|
Quote:
The letters here stand for a set such that if the variable is one of the items in one particular set, it choses the input that that set returns.
One approach is to do an if, retesting the field like this:
if "%1" = "Assassin" or _
"%1" = "Diamond Helmet" or _
"%1" = "Pearl Lance" then
' do something
end if
Another approach is to use "select case" like this:
Select Case "%1"
Case "Assassin" ' do something
Case "Diamond Helmet" ' do something
Case "Pearl Lance" ' do something
Case Else ' do something else
End Select
Personally I would use Lua these days. You could select by doing a table-lookup quite efficiently.
Quote:
I'm curious as to why you omited the wild card at the end if the match
A match like this has an implied trailing wildcard:
Match= "^blah blah"
This is because you are not matching on the end-of-line.
This is similar to:
Match= "^blah blah.*$"
In any case, your match text looks like a regular expression, you should check "regular expression" box.
It looks like you are typing these in by hand, it is easier to use the GUI interface. |
- 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.
16,176 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top