scan script problems

Posted by Thebloodsiren on Mon 20 May 2002 01:49 AM — 8 posts, 26,834 views.

#0
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)
Australia Forum Administrator #1
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");
#2
Oops, I posted this under javascript, when I write in Vb.
So your answer in Vb makes sense.

Thankx
Australia Forum Administrator #3
In that case I'll move it into the correct section. :)
#4
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
#5
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
Australia Forum Administrator #6
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
#7
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.