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
➜ Trigger, Variable, Alias, Timer problem?
Trigger, Variable, Alias, Timer problem?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Chronoti
USA (27 posts) Bio
|
Date
| Wed 24 Sep 2003 07:18 PM (UTC) |
Message
| Alright, here i am again, always asking questions, but... this time... its not important. hah jk, anyways, here is the problem, I want to cast a spell, then 2 seconds later, cast it again if I am still in a fight, so I figure, Make a variable contain "on" so if the variable is on, then I continue casting, but if the mob dies, then the variable is set to "off" that way... it stops casting... here is the alias for "shocking grasp"
grasp = world.getVariable("shockinggrasp")
world.setVariable "fight", "on"
fight = world.getVariable("fight")
if fight="on" then
world.send grasp & " %1"
world.DoAfter 1, sg & "%1"
end if
ok here is the problem, how do I send lets say the alias "sg *" again? I tried at the "world.doAfter" but it only sends the %1 expanded... how do I execute the alias? and I just noticed another problem with my script, but I can do that... Thanks for any help! | Top |
|
Posted by
| Chronoti
USA (27 posts) Bio
|
Date
| Reply #1 on Wed 24 Sep 2003 07:51 PM (UTC) |
Message
| also another question, how would I do 2.. "world." commands in the same throw? such as...
world.DoAfter 2, world.SetVariable "fight", "off"
thats just an example... um... thanks. | Top |
|
Posted by
| Magnum
Canada (580 posts) Bio
|
Date
| Reply #2 on Thu 25 Sep 2003 07:38 PM (UTC) Amended on Thu 25 Sep 2003 07:41 PM (UTC) by Magnum
|
Message
| The new trend is to write script directly in your aliases, triggers, etc. For this occasion, I would probably create the following script in your main script file:
Dim Fight
Dim LastTarget
Sub Cast_Shocking_Grasp (AliasName, AliasLine, Wildcards)
LastTarget = Wildcards(1)
Fight = True
Repeat_Shocking_Grasp "Cast_Shocking_Grasp"
End Sub
Sub Repeat_Shocking_Grasp (TimerName)
If Fight Then
World.LogSend World.GetVariable("shockinggrasp") & LastTarget
World.AddTimer "ShockingGraspTimer", 0, 0, 2, "", 5, "Repeat_Shocking_Grasp"
End If
End Sub
Create a Shocking Grasp alias, and in the "Script" box enter "Cast_Shocking_Grasp". When the script is called, it stores the target for your spell in a variable, sets 'Fight' to True, and then immediately calls the "Repeat_Shocking_Grasp" subroutine.
The subroutine "Repeat_Shocking_Grasp" then sends the line once immediately, and creates a timer to call itself again in 2 seconds. This process will repeat until you set "Fight = False" elsewhere, such as in your trigger that detects the mob has been killed. |
Get my plugins here: http://www.magnumsworld.com/muds/
Constantly proving I don't know what I am doing...
Magnum. | Top |
|
Posted by
| Chronoti
USA (27 posts) Bio
|
Date
| Reply #3 on Fri 26 Sep 2003 04:44 AM (UTC) |
Message
| oi, so I have it in a script file, which calls fine, but I um... dunno how to use that script, i am looking, and reading different functions and how to call subs (yes I know how now haha) but how would I call the sub correctly? I get all kinds of errors, I fix one, and another one shows up... so like... alias:
sg *
Cast_Shocking_Grasp "something", "something", "something"
right? well.. ok not right, because it didn't work, what should I be doing? *bangs head on keyboard klafjds* Sorry, that got ugly there, keyboard is stupid. | Top |
|
Posted by
| Magnum
Canada (580 posts) Bio
|
Date
| Reply #4 on Fri 26 Sep 2003 11:54 AM (UTC) |
Message
| Nah... You don't need to provide those three arguments manually. They are sent automatically by MUSHclient whenever an alias or trigger calls a subroutine.
Indeed, you must program you subroutines to accept the correct number of arguments, or your script will fail.
Both aliases and triggers, when calling a script, attempt to pass 3 arguments:
Alias/Trigger Name - The name of the alias or trigger making the call to the subroutine.
Alias/Trigger Line - The entire line inputted at the command prompt that called the script, or the entire line that the trigger fired on, which called the script.
Wildcards - The alias or trigger wildcards.
Timers are slightly different. When a MUSHclient Timer fires and attempts to call a script, it automatically passes just one argument, which is the name of the timer.
Anyway, in this case, an alias like this should work for you:
<aliases>
<alias
name="Alias_Shocking_Grasp"
script="Cast_Shocking_Grasp"
match="sg *"
enabled="y"
sequence="100"
>
</alias>
</aliases>
Your last step will be to create a trigger that fires when the mob dies, and then use script to set "Fight = False". You may be able to simply do that in the send box, and send to script. |
Get my plugins here: http://www.magnumsworld.com/muds/
Constantly proving I don't know what I am doing...
Magnum. | Top |
|
Posted by
| Chronoti
USA (27 posts) Bio
|
Date
| Reply #5 on Fri 26 Sep 2003 04:24 PM (UTC) |
Message
| hrm, sorta strange, I did like you said, and made it so I can see any triggers (I turned on echoing), anyways all it sends to the mud when i type: "sg giant" is... "giant" and not cast 'shocking grasp' giant
What I did, was open up the mud xml file, and put that alias directly in (made sure removing the <aliases> </aliases>) tag from either end, and saved it, then opened up the mud, but it just sends giant... oi I fill stupid. | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #6 on Fri 26 Sep 2003 11:46 PM (UTC) |
Message
|
Quote:
how do I send lets say the alias "sg *" again? I tried at the "world.doAfter" but it only sends the %1 expanded... how do I execute the alias?
See:
http://www.gammon.com.au/scripts/doc.php?function=DoAfterSpecial
You need to use DoAfterSpecial to "send to execute" which will cause the alias to be evaluated. eg.
world.DoAfterSpecial 1, "sg %1", 10
Of course, be a bit careful - doing this will cause "sg" to be called every 10 seconds indefinitely.
Quote:
also another question, how would I do 2.. "world." commands in the same throw? such as...
world.DoAfter 2, world.SetVariable "fight", "off"
Use DoAfterSpecial to "send to script" - that way you can queue up a command to be scripted later. Here is an example. Note the double quotes in the SetVariable because we have quotes within quotes.
world.DoAfterSpecial 2, "world.SetVariable ""fight"", ""off""", 12
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Magnum
Canada (580 posts) Bio
|
Date
| Reply #7 on Sat 27 Sep 2003 12:24 PM (UTC) Amended on Sat 27 Sep 2003 12:25 PM (UTC) by Magnum
|
Message
| Way back in your original message, you set the variable "grasp" to World.GetVariable("shockinggrasp"). I wasn't sure why you did that, so when I wrote the script for you, I essentially maintained the same functionality. I assumed the value of GetVariable("shockinggrasp") was the text required to cast the spell.
If you are only getting the target sent to the mud, then the contents of the above variable must be empty. Frankly, I'm not sure why you had that variable anyway. I would just find this line in the script I provided to you, and change it:
World.LogSend World.GetVariable("shockinggrasp") & LastTarget
Change it to:
World.LogSend "cast 'shocking grasp' " & LastTarget
...or put whatever the command is on your mud to cast Shocking Grasp, within those quotes. Be sure to leave a trailing space before the end quote, so that the target gets sent as the following (seperate) word. |
Get my plugins here: http://www.magnumsworld.com/muds/
Constantly proving I don't know what I am doing...
Magnum. | Top |
|
Posted by
| Chronoti
USA (27 posts) Bio
|
Date
| Reply #8 on Sat 27 Sep 2003 05:06 PM (UTC) |
Message
| Thank you very much Magnum, and Nick as well, I can't try the script at the moment, but I will when I get home from work tonight... Again thanks for your time and help! | 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.
27,070 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top