Register forum user name Search FAQ

Gammon Forum

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 ➜ Scripting Target System

Scripting Target System

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by You_know   (2 posts)  Bio
Date Thu 22 Jan 2004 09:11 PM (UTC)
Message
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?
Top

Posted by Shadowfyr   USA  (1,792 posts)  Bio
Date Reply #1 on Thu 22 Jan 2004 11:46 PM (UTC)
Message
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>

Top

Posted by You_know   (2 posts)  Bio
Date Reply #2 on Fri 23 Jan 2004 03:44 AM (UTC)
Message
So..I don't know how to get all that into the client..like how to make it work..where to put it.. ?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Fri 23 Jan 2004 04:50 AM (UTC)

Amended on Fri 23 Jan 2004 04:51 AM (UTC) by Nick Gammon

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

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


14,385 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.