| 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 |
|