[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Calling info from Output and placing it into an alias

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Calling info from Output and placing it into an alias

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Exodus   (12 posts)  [Biography] bio
Date Sat 25 May 2002 10:01 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 26 May 2002 01:45 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Helio   (9 posts)  [Biography] bio
Date Reply #2 on Fri 19 Jul 2002 09:59 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Helio   (9 posts)  [Biography] bio
Date Reply #3 on Fri 19 Jul 2002 10:01 AM (UTC)  quote  ]
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?
[Go to top] top

Posted by Magnum   Canada  (580 posts)  [Biography] bio
Date Reply #4 on Fri 19 Jul 2002 07:02 PM (UTC)  quote  ]
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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Fri 19 Jul 2002 11:14 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Thu 01 Aug 2002 12:51 AM (UTC)  quote  ]
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
[Go to top] 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.


2,478 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]