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
➜ Calling info from Output and placing it into an alias
|
Calling info from Output and placing it into an alias
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Exodus
(14 posts) Bio
|
| Date
| Sat 25 May 2002 10:01 AM (UTC) |
| Message
| Hi,
I'm not too good with scripting and such, and have a little problem with scripting this, hopefully you can help me out.
When I enter this command "locate Mr.X", 3 lines of infomation will appear in the output. For example :
Mr.X is in the Great city of Nova {or name of area}
In the room: a dark alley {or name of room}
Mr.X is idle {or his status}
I would then like to copy all these 3 lines of information and send it to a friend who would like to know of his whereabouts.
Example: tell Bountyhunter Mr.X is in the Great city of Nova {or name of area};In the room: a dark alley {or name of room}and is idle {or his status}
Yet, if i tried to locate someone else, the new information will be copied and ready for me to send it to another friend, and not retaining the old information. Is this possible?
Much appreciated | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Sun 26 May 2002 01:45 AM (UTC) |
| Message
| Interesting challenge. :)
You need 3 triggers (one for each line that tells you about Mr.X) and one alias, to start the ball rolling. The triggers are initially disabled, so they don't fire if a line happens to arrive with "is" in it (3rd trigger).
Make sure scripting is enabled, and that VBscript is the active language. Edit the script file (or start a blank one called "myscript.vbs" for instance) and copy and paste the lines below between the rules:
sub OnLocate (sName, sLine, wildcards)
world.setvariable "target", wildcards (1)
world.send "locate " & wildcards (1)
world.enabletrigger "AreaName", 1 ' ready for first trigger
end sub
sub OnAreaName (sName, sLine, wildcards)
if wildcards (1) = world.getvariable ("target") then
world.setvariable "area", wildcards (2)
world.enabletrigger "RoomName", 1 ' ready for next trigger
world.enabletrigger sName, 0 ' disable ourselves
end if
end sub
sub OnRoomName (sName, sLine, wildcards)
world.setvariable "room", wildcards (1)
world.enabletrigger "Status", 1 ' ready for next trigger
world.enabletrigger sName, 0 ' disable ourselves
end sub
sub OnStatus (sName, sLine, wildcards)
if wildcards (1) = world.getvariable ("target") then
world.setvariable "status", wildcards (2)
world.enabletrigger sName, 0 ' disable ourselves
world.send "tell " & _
world.getvariable ("friend") & " " & _
world.getvariable ("target") & " is in " & _
world.getvariable ("area") & "; in room " & _
world.getvariable ("room") & "; status " & _
world.getvariable ("status")
end if
end sub
Now in the scripting configuration set the appropriate script file name as the script file (eg. myscript.vbs).
You should then set up who your friend is, like this. Type:
/world.setvariable "friend", "my_friends_name"
This will establish the variable "friend" with his name in it. You can also do it through the world configuration, "variables" screen.
Finally, add the following 3 triggers and one alias. If you are using version 3.22 of MUSHclient the simple way is to:
- Copy the lines below between the rules
- Go to File menu -> Import -> Clipboard
That will add them for you.
<aliases>
<alias
name="Locate"
script="OnLocate"
match="locate *"
enabled="y"
>
</alias>
</aliases>
<triggers>
<trigger
custom_colour="2"
ignore_case="y"
match="* is in *"
name="AreaName"
script="OnAreaName"
sequence="100"
>
</trigger>
<trigger
custom_colour="2"
ignore_case="y"
match="In the room: *"
name="RoomName"
script="OnRoomName"
sequence="100"
>
</trigger>
<trigger
custom_colour="2"
ignore_case="y"
match="* is *"
name="Status"
script="OnStatus"
sequence="100"
>
</trigger>
</triggers>
Then just type "locate x" where "x" is who you want to locate.
What this will do is the "locate" command will go to the alias, which will remember "x" as the person you are locating.
It then enables the first trigger. When the first trigger fires (eg. "Mr.X is in the Great city of Nova") it remembers where x is, disables itself, and enables the second trigger.
When the second trigger fires (eg. "In the room: a dark alley") it remembers which room x is in, disables itself, and enables the third trigger.
When the third trigger fires (eg. "Mr.X is idle") it remembers his status, disables itself, and then does a "tell" to whoever "friend" is, passing the results from all three triggers. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Helio
(9 posts) Bio
|
| Date
| Reply #2 on Fri 19 Jul 2002 09:59 AM (UTC) |
| Message
| Ok, I am sorry but I am new to this scripting thing..
I ain't using 3.22 so I cant add an alias by importing. and when i try to add the alias manually i cant put in the script cause it doesnt allow u to add anything in the box. i am currently using 3.20
Please help.
Thanks | | Top |
|
| Posted by
| Helio
(9 posts) Bio
|
| Date
| Reply #3 on Fri 19 Jul 2002 10:01 AM (UTC) |
| Message
| | Oh and when you set the world variable my friend "my_friends_name" u only set one name correct? what if i need to change the name constantly? does that mean i have to edit it everytime i am sending a tell to a new friend? | | Top |
|
| Posted by
| Magnum
Canada (580 posts) Bio
|
| Date
| Reply #4 on Fri 19 Jul 2002 07:02 PM (UTC) |
| Message
| | You need to assign the alias a name before you can have it call a script. |
Get my plugins here: http://www.magnumsworld.com/muds/
Constantly proving I don't know what I am doing...
Magnum. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #5 on Fri 19 Jul 2002 11:14 PM (UTC) |
| Message
| You could make an alias, eg.
friend *
That calls a small script that takes the * (the wildcard that is the friend's name) and sets the variable for you. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #6 on Thu 01 Aug 2002 12:51 AM (UTC) |
| Message
|
Quote:
I ain't using 3.22 so I cant add an alias by importing. and when i try to add the alias manually i cant put in the script cause it doesnt allow u to add anything in the box. i am currently using 3.20
Just add them manually, following your nose for each field. You may need to enable scripting to let it add the script name. Make sure you put the label in first or it won't accept the script name. |
- 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.
24,158 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top