more vb script help

Posted by Shou on Mon 03 May 2010 10:42 PM — 25 posts, 94,930 views.

USA #0
ok, i have heard, but not too sure about this, that you can start a timer off of a trigger. how would i do this?

another thing is this:
trigger
"You suddenly perceive the vague outline of an aura of rebounding around (whoever)"

send
"world.SetVariable "rebounding", "on" "

this is getting set off each time the message pops up.
is there a way to make the trigger set off when the (whoever) part is my variable @npc?


also (although this one can wait if need be) i need a little help on making a trigger, umm, start a timer after a message goes through the server, then disable it after the timer fires. erm, and i know it is asking alot, but is it possible to make the action carried out by the timer check to see if i have balance or equilibrium?
Amended on Tue 04 May 2010 12:07 AM by Shou
Australia Forum Administrator #1
Shou said:

ok, i have heard, but not too sure about this, that you can start a timer off of a trigger. how would i do this?


Send to script, and in the script see DoAfter, AddTimer and similar.



Shou said:

this is getting set off each time the message pops up.
is there a way to make the trigger set off when the (whoever) part is my variable @npc?


Check "expand variables" and the npc name will be substituted in the trigger match text.

Shou said:

also (although this one can wait if need be) i need a little help on making a trigger, umm, start a timer after a message goes through the server, then disable it after the timer fires. erm, and i know it is asking alot, but is it possible to make the action carried out by the timer check to see if i have balance or equilibrium?


In the trigger, it can disable itself, see EnableTrigger function.

As for balance and equilibrium, you can have other triggers to check for that (eg. from your prompt) so that the first trigger will know if you have them or not (by saving if you have balance, or not, in a variable).
USA #2
wow, thanks alot!
USA #3
ok, in enable trigger, when it says:

world.EnableTrigger "(whatever", TRUE '

is the (whatever) part of it what the trigger fires off of? like the like "you are hungry" would it be

world.enabletrigger "you are hungry", true' ?
Australia Forum Administrator #4
No, it is the trigger name. When editing a trigger you can give it a name (label). That is what you use.
USA #5
oooh, ok. i never knew what label was for so i never put anything in it. thanks again
USA #6
ok, new problem.
i have set up a trigger. this trigger already had a function to change a variable for me. I used the DoAfterSpecial function with it as a second task. i want it to execute my alias "a", but i cannot seem to get it to work, as of now, i have
world.DoAfterSpecial 2.3, "world.execute "a", 12

what am i doing wrong?
also, how would i make it do different things inside one DAS?
would i need to put the /n?
USA #7
ok sorry that i have many questions, but i also have many problems, including the one before this, i have a problem with the EvaluateSpeedwalk function.
(im not going to lie here..)
this is what i have
world.note world.EvaluateSpeedwalk ("s(se)n(agree viannos)s(nw)2n(ne)e(drop ladder)(take pomegranate)(take pomegranate)(take pomegranate)e(sw)2s(se)n(give pomegranate to viannos)(give pomegranate to viannos)(give pomegranate to viannos)s(nw)nd")

whenever i try to fire it, it gives me

*Invalid direction "r" in speedwalk, must be N, S, E, W, U, D, F, or (something)

i don't know where it is finding "r" in there, other than inside the (agree viannos) and (take pomegranate) among other (somethings)

i am sending this to Speedwalk, with only enable checked off.
Australia Forum Administrator #8
That is a script, not a speedwalk. In the first word "world" it is accepting "w" for west, "o" for open, and then objects to "r".

Change it to "send to script".
Australia Forum Administrator #9
Shou said:


world.DoAfterSpecial 2.3, "world.execute "a", 12

what am i doing wrong?



You have quotes within quotes there (that is, only three quotes - you aren't closing the quote for "world.execute").

Anyway, it would be simpler to send to execute, rather than doing world.execute. That is:


DoAfterSpecial 2.3, "a", 10


That re-evaluates "a" as a command (so it will pick up the alias "a").

To do multiple things you could probably add line breaks with vbCrLf, or just call a script and in the script do multiple things. eg.


DoAfterSpecial 2.3, "Call myfunc", 12


And in your script file have:


Function myfunc ()
  Send "say hello"
  Send "say my friend"
End Function


USA #10
ok, wow. i am sorry to have wasted your time, but i seem to have misunderstood what the Evaluatespeedwalk function does. i am looking for something that will actually DO the speedwalk, not just show me what it is, would this be DoAfter(special?)Speedwalk, or something else entirely.

oh, and the send to script made it work though, thanks for that!
Australia Forum Administrator #11
In that case just put the speedwalk there (not the EvaluateSpeedwalk or the quotes) - just the raw speedwalk. Then change it to "send to speedwalk".
Australia Forum Administrator #12
As for pausing, you are probably better off using Lua rather than VBscript (they are fairly similar for beginners) and then see this post:

Template:post=4956
Please see the forum thread: http://gammon.com.au/forum/?id=4956.


That lets you send things, pause, send other things, loop, etc.
USA #13
ok first of all, i would like to say thank you Nick for all the help you have given me.
i have decided to stay with VBscript for now.

the problem this time, is that if my target has a really long name, i would like to be able to make it recognize what i have as my @npc+ letters or not.
an example would be something like :
npc= diak

trigger: diaktoros touches a small tree.
what i have @npc touches a small tree.

what would i put after @npc to recognize the 'toros' but still work if there is nothing after my @npc?
Australia Forum Administrator #14

<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   match="@npc* touches a small tree."
   send_to="2"
   sequence="100"
  >
  <send>matched!</send>
  </trigger>
</triggers>


Template:copying
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.
USA #15
ok, i know this is somewhere here, but i can't find it. This is what i have right now:

<aliases>
  <alias
   match="tdart *"
   enabled="y"
   expand_variables="y"
   sequence="100"
  >
  <send>twinshot @npc %1</send>
  </alias>
</aliases>


is there a way to make this work, when the * might not be there? the * is replacing a direction, btw.
Amended on Thu 27 May 2010 04:00 AM by Shou
Australia Forum Administrator #16
Template:faq=50
Please read the MUSHclient FAQ - point 50.
USA #17
ok, looks like i need some help here. i have an alias that helps me preserve toxins, and this is what i have:

<aliases>
  <alias
   match="preserve"
   enabled="y"
   expand_variables="y"
   send_to="12"
   sequence="1"
  >
  <send>if getvariable ("toxinstorage") = ("0") then
world.send "preserve toxin in vial"
world.SetVariable "toxinstorage", "1"
end if
if getvariable ("toxinstorage") = ("1") then
world.send "preserve toxin in vial"
world.SetVariable "toxinstorage", "2"
end if
if getvariable ("toxinstorage") = ("2") then
world.send "preserve toxin in vial"
world.send "drop vial"
world.SetVariable "toxinstorage", "0"
end if</send>
  </alias>
</aliases>


although i have this, it sends

preserve toxin in vial
preserve toxin in vial
preserve toxin in vial
drop vial

each time it is used. did i mess something up in the function?
Australia Forum Administrator #18
Well, yes.

You start off like this:


if getvariable ("toxinstorage") = ("0") then
  world.send "preserve toxin in vial"
  world.SetVariable "toxinstorage", "1"
end if


So now the variable "toxinstorage" is 1.

Then immediately afterwards you test if it is 1 (which it is, now):


if getvariable ("toxinstorage") = ("1") then
  world.send "preserve toxin in vial"
  world.SetVariable "toxinstorage", "2"
end if


So you do that as well. Then you set the variable to 2. Then you test if it is 2 (which it is now). You need to use "else" to stop all the ifs succeeding at once.
Australia Forum Administrator #19
One way would be to use "expand variables" as that is done at the start (by which I mean, once the variables are expanded, they don't change during the running of the script). Something like this:


if @toxinstorage = 0 then
  Send "preserve toxin in vial"
  SetVariable "toxinstorage", "1"
end if

if @toxinstorage = 1 then
  Send "preserve toxin in vial"
  SetVariable "toxinstorage", "2"
end if

if @toxinstorage = 2 then
  Send "preserve toxin in vial"
  Send "drop vial"
  SetVariable "toxinstorage", "0"
end if
Amended on Thu 03 Jun 2010 06:36 AM by Nick Gammon
USA #20
thanks! i never would have figured this out alone
Amended on Thu 03 Jun 2010 05:10 AM by Shou
USA #21
ok, i have a problem. i just recently made the alias bf, which does this (Sorry for the length):

<aliases>
  <alias
   match="bf"
   enabled="y"
   expand_variables="y"
   send_to="12"
   sequence="100"
  >
  <send>if getvariable ("stance") = ("Gyanis") and getvariable ("surge") = ("off") then
if @stance = Gyanis and @surge = off then
world.execute "change stance vae-sant"
end if
if getvariable ("stance") = ("Vae-Sant") and getvariable ("surge") = ("off") then
world.send "sitara butterfly @npc"
world.send "trip @npc"
world.send "pindown @npc"
end if
if getvariable ("stance") = ("Rizet") and getvariable ("surge") = ("off") then
world.send "sitara butterfly @npc"
world.send "trip @npc"
world.send "pindown @npc"
end if
if getvariable ("stance") = ("Laesan") and getvariable ("surge") = ("off") then
world.send "sitara butterfly @npc"
world.send "trip @npc"
world.send "pindown @npc"
end if
if getvariable ("stance") = ("Ein-Fasit") and getvariable ("surge") = ("off") then
world.send "sitara butterfly @npc"
world.send "Trip @npc"
world.send "pindown @npc"
end if
if getvariable ("stance") = ("Gyanis") and getvariable ("surge") = ("on") then
world.execute "change stance vae-sant"
end if
if getvariable ("stance") = ("Vae-Sant") and getvariable ("surge") = ("on") then
world.send "sitara butterfly @npc"
world.send "trip @npc"
world.send "pindown @npc"
world.send "mindumb @npc"
end if
if getvariable ("stance") = ("Rizet") and getvariable ("surge") = ("on") then
world.send "sitara butterfly @npc"
world.send "trip @npc"
world.send "pindown @npc"
world.send "mindumb @npc"
end if
if getvariable ("stance") = ("Laesan") and getvariable ("surge") = ("on") then
world.send "sitara butterfly @npc"
world.send "trip @npc"
world.send "pindown @npc"
world.send "mindumb @npc"
end if
if getvariable ("stance") = ("Ein-Fasit") and getvariable ("surge") = ("on") then
world.send "sitara butterfly @npc"
world.send "trip @npc"
world.send "pindown @npc"
world.send "mindumb @npc"
End if</send>
  </alias>
</aliases>


now, when i try to fire it, it gives me this:

Script error
World: imperian
Execution of line 51 column 7
Immediate execution
Expected 'End'
Line in error:
end if

even though i don't have anything in column 7 line 51 (last line, the column after the 'f' in if), no spaces, nothing.
USA #22
I bet you this isn't what you wanted:

if @stance = Gyanis and @surge = off then


It'll treat Gyanis and off as VBscript variables, not string values. Also, @stance's value will be unquoted. Did you mean:

if "@stance" = "Gyanis" and "@surge" = "off" then



EDIT: Also, you have these lines as the first two lines:

if getvariable ("stance") = ("Gyanis") and getvariable ("surge") = ("off") then
if @stance = Gyanis and @surge = off then


I don't see a matching 'end if' for the first one. Methinks one of those is redundant. If you -did- mean to do that - even though the intent of the checks are exactly the same - add another "end if" to the end of the script (or wherever it's supposed to go).
Amended on Fri 25 Jun 2010 04:09 AM by Twisol
USA #23
ah yes. i didn't notice those first two lines. thanks for the help
USA #24
ok, this time, i am trying to highlight a line that comes in with a group like this:

      Oramashi - Victory Circle               (590) - City of Antioch.
          Rait - Kinsarmar Crossroads         (103) - City of Kinsarmar.
          Ramm - The Mounted Cephyreid      (15186) - Ithaquan Council.


how would iget the Rait - Kinsarmar crossroads line highlighted, with 'Rait' as a wildcard?

oh, and the area before the names is just empty space.