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
➜ scan script problems
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Thebloodsiren
(13 posts) Bio
|
| Date
| Mon 20 May 2002 01:49 AM (UTC) |
| Message
| Can someone help me with two things, Ive only just started to get into Mushclient scripting and Im not a whiz at coding by nature.
*****
Firstly,
I want to make a scan script that will read the exits in the room, and upon calling the script (ie an alias will call the scan script). The scan script will look in the directions.
For example the mud provides text like this:
Obvious exits: n e se(closed) gate
My idea was to have a trigger read the exits and set them to a variable. Everytime I move the trigger will reupdate the "obvious exits" in the particular room im in. When the alias entered tos run the script, it will look though the variable (and the obvious exits stored inside it), expand and do: (using the example above):
look north
look east
open southeast
look southeast
look gate
My major problems is I dont know how to manipulate the variable that will contain "n e se(closed) gate" so that a script can go through it.
Ideas?
*****
Secondly, I have a trigger that a script creates for use in pk. What the trigger sends back upon firing is what I am having troubles with. I want to be able to change what the trigger sends and have more than one line of commands send triggered.
ie i may want the trigger to send these commands
follow <victim>
backstab <victim>
or at othertimes
bash <victim>
cast 'acid blast' <victim>
etc
I cannot work out how using the world.addtrigger command i can get the trigger to send more than one command. I tried having the trigger call a variable, but once again cannot work out how to make a variable contain more than one line of text. Alternatively I could make the trigger call a script with the commands inside. I say again I would like the actions that the trigger sends be easy to change, and preferably not needing to bring up the mushiclient configuration console (for in pk, i need the scripts to run fast. Hence just write an alias that will update my actions upon the trigger firing) |
-----------------------------------
Calm down, its only ones and zeros. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Mon 20 May 2002 03:04 AM (UTC) |
| Message
|
Quote:
My major problems is I dont know how to manipulate the variable that will contain "n e se(closed) gate" so that a script can go through it.
In VBscript you can do this:
for each x in split ("n s e w")
world.send "look " & x
next
So, you could take the exits (say, the first wildcard) and use something similar to that. I'm not sure of the JScript equivalent.
Quote:
I want to be able to change what the trigger sends and have more than one line of commands send triggered.
To send multiple lines you just put a carriage-return/linefeed into the string.
eg.
world.send "north" & vbCrLf & "south"
In JScript the equivalent is:
world.send ("north\r\nsouth");
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Thebloodsiren
(13 posts) Bio
|
| Date
| Reply #2 on Mon 20 May 2002 03:28 AM (UTC) |
| Message
| Oops, I posted this under javascript, when I write in Vb.
So your answer in Vb makes sense.
Thankx |
-----------------------------------
Calm down, its only ones and zeros. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #3 on Mon 20 May 2002 04:13 AM (UTC) |
| Message
| | In that case I'll move it into the correct section. :) |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Thebloodsiren
(13 posts) Bio
|
| Date
| Reply #4 on Wed 22 May 2002 05:29 AM (UTC) |
| Message
| thankx for the help, i got around to testing it. Whats wrong here?
I have a trigger that matches the "*obvious exits: *" and passes it to the variable "EXITS". The two wildcards are set up correctly so it isnt the problem. The problem is that it wont scan the variable and look in all the directions.
sub exits(name,output,wildcards)
world.SetVariable "EXITS", wildcards (2)
for each x in split & world.getvariable"EXITS"
world.send "look " & x
next
end sub |
-----------------------------------
Calm down, its only ones and zeros. | | Top |
|
| Posted by
| Thebloodsiren
(13 posts) Bio
|
| Date
| Reply #5 on Wed 22 May 2002 05:38 AM (UTC) |
| Message
| Got it sorted out by luck
sub exits(name,output,wildcards)
world.SetVariable "EXITS", wildcards (2)
for each x in split ("" & world.getvariable("EXITS"))
world.send "look " & x
next
end sub |
-----------------------------------
Calm down, its only ones and zeros. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #6 on Wed 22 May 2002 08:20 AM (UTC) |
| Message
| Very good. However concatenating an empty string won't do much, and you may not need to save the wildcard as a variable. Here is the shortest solution:
sub exits(name,output,wildcards)
for each x in split (wildcards (2))
world.send "look " & x
next
end sub
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Thebloodsiren
(13 posts) Bio
|
| Date
| Reply #7 on Thu 23 May 2002 01:25 AM (UTC) |
| Message
| Yes that would work. I store the exits in a variable because i dont wont to 'scan' the exits everytime i move - just at special times. The way i have it currently is that i update the exits into a variable through the use of a trigger, and have an alias that lets me "scan" through all the exits when i want to.
My full scripts are like this (in case anyone is interested)
'*****Scan Exits Script*****
sub ToggleExitTrigger(name,output,wildcards)
if world.GetTriggerInfo ("UpdateExits", 8)=0 then
world.AddTrigger "UpdateExits", "*Obvious exits: *", "", 17417, -1, 0, "", "UpdateExits"
world.AddAlias "ScanExits", "scan","", 17409, "ScanExits"
world.note "Enabling Exit Updates
else
world.enabletrigger "UpdateExits", false
world.DeleteVariable "EXITS"
world.note "Disabling Exit Updates"
end if
end sub
sub UpdateExits(name, output, wildcards)
world.SetVariable "EXITS", wildcards (2)
end sub
sub ScanExits(name,output,wildcards)
for each x in split ("" & world.getvariable("EXITS")) world.send "look " & x
next
end sub
'*****
Basically the ToggleExitTrigger is assingned to a Macro or an Alias and lets me toggle on/off the whole system. (the script creates the trigger that updates the variable storing the exits, and also the alias that i use to "scan")
UpdateExits is linked to my trigger so it updates the exits each time i move around the mud world.
ScanExits is linked to an alias or macro so you can look in the directions currently stored in the Exits variable.
For now it seems to work, if you had any improvements on code efficiency etc it would be handy. I dont want to slow the mushclient down too much. |
-----------------------------------
Calm down, its only ones and zeros. | | 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.
25,115 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top