Scripting Target System

Posted by You_know on Thu 22 Jan 2004 09:11 PM — 4 posts, 15,101 views.

#0
Yeah...I'm new to the whole scripting thing and was wondering how exactly you'd go about getting a targetting system in there. I found a little something for it, just not sure how to get it into the client.

alias name: atar
commands: #additem preylist %1;#var prey %1
that adds into your list preylist all the people you after
then sets the new add as your primary target

alias name: dtar
commands: #var counter %numitems(@preylist);#loop %numitems(@preylist) {#say {<%i>: <%item(@preylist,<%i>)>}}
that displays the targets on your prompt
and the number assigned to them

alias name: star
commands: #var prey <%item(@preylist,%1)>
switches between the targets

alias name: ctar
commands : #loop %numitems(@preylist) {#delnitem preylist (1)}
that clears your preylist


That's what I found. Now..is that right? How do I do this?
USA #1
Hmm. This could be interesting.. So I'll give it a crack.

<aliases>
  <alias
   name="atar"
   script="Add_Target"
   match="^atar .*"
   regexp="y"
   enabled="y"
  >
  </alias>
  <alias
   name="dtar"
   script="Display_Targets"
   match="^dtar"
   regexp="y"
   enabled="y"
  >
  </alias>
  <alias
   name="star"
   script="Set_Target"
   match="^star .*"
   regexp="y"
   enabled="y"
  >
  </alias>
  <alias
   name="ctar"
   script="Clear_Targets"
   match="^ctar"
   regexp="y"
   enabled="y"
  >
  </alias>
</aliases>

dim preylist() 'This is our dynamic list. 

sub Add_Target(AName, ouput, wilds)
  temp = ubound(preylist)
  if temp = 0 and preylist(0) = "" then
    preylist(0) = wilds(1)
  else
    redim preserve preylist(temp + 1)
    preylist(temp + 1) = wilds(1)
  end if
end sub

sub Display_Targets(AName, output, wilds)
  for count = 0 to ubound(preylist)
    note count & ": " & preylist(count)
  next
end sub

sub Set_Target(AName, output, wilds)
  if wilds(1) < 0 or wilds(1) > ubound(preylist) then
    colournote "red","black","No such target in list!"
  else
    'We use a mushclient variable, so aliases can use the contents
    'directly.
    setvariable "prey", preylist(wilds(1))
  end if
end sub

sub Clear_Targets(AName, output, wilds)
  redim preylist(0)
  preylist(0) = ""
end sub

This *should* work, but I haven't tested it. To use the variable 'prey' you would then do something like:

<aliases>
  <alias
   match="kill"
   enabled="y"
   expand_variables="y"
   sequence="100"
  >
  <send>kill @prey</send>
  </alias>
</aliases>

#2
So..I don't know how to get all that into the client..like how to make it work..where to put it.. ?
Australia Forum Administrator #3
These lines:



dim preylist() 'This is our dynamic list. 

sub Add_Target(AName, ouput, wilds)
  temp = ubound(preylist)
  if temp = 0 and preylist(0) = "" then
    preylist(0) = wilds(1)
  else
    redim preserve preylist(temp + 1)
    preylist(temp + 1) = wilds(1)
  end if
end sub

sub Display_Targets(AName, output, wilds)
  for count = 0 to ubound(preylist)
    note count & ": " & preylist(count)
  next
end sub

sub Set_Target(AName, output, wilds)
  if wilds(1) < 0 or wilds(1) > ubound(preylist) then
    colournote "red","black","No such target in list!"
  else
    'We use a mushclient variable, so aliases can use the contents
    'directly.
    setvariable "prey", preylist(wilds(1))
  end if
end sub

sub Clear_Targets(AName, output, wilds)
  redim preylist(0)
  preylist(0) = ""
end sub



Copy and paste them into a Notepad window (a text file) and save as something.vbs.

Then turn scripting on in the Configuration window, language VBscript, and browse for your script file (something.vbs). That will make the script available.

Then copy the two batches between:

<aliases> ... </aliases>

Go into the aliases configuration screen and click on the "paste" button (once for each batch). That will add the aliases to the client.