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
➜ cycling through variables
|
cycling through variables
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Bobble
Canada (76 posts) Bio
|
| Date
| Sun 23 Jun 2002 05:54 PM (UTC) |
| Message
| Greets all,
I'm embarassingly new to scripting and programming of any kind. Everything I've learned of scripting has been learned in the last couple of days, so I may be asking a very basic question.
Anyway, on the MUD I'm playing there are several afflictions (i.e. blindness, nausea, etc.) you can be given via poisons and what not. Each of these afflictions can be cured by eating a certain type of plant. My problem is that you're only allowed to eat a plant every two seconds, but you can be given several different afflictions at once. I need a way to keep track of what I've been afflicted with and then automatically eat the appropriate plants.
For instance, if I'm afflicted with blindness and nausea at the same time, I'll need to have "eat bloodroot" sent to the MUD to cure the blindess and then have "eat ginseng" sent two seconds later to cure the nausea.
What I've done so far is set up variables for each of the afflictions. The name of each of these variables starts with affliction_ followed by the affliction name ,so the variable for blindness is called affliction_blindness. I've set up triggers to change the contents of each of these variables if I've been afflicted with them. So if I'm given blindess, the contents of the affliction_blindness variable will be set to "on" and if I'm cured of the blindness, the contents will be set to "off"
What I need now is a script that can be run that will cycle through each of these afflictions, find all the ones that are "on" and put the appropriate plants into a queue that will send "eat <next plant in queue>" to the mud every 2 seconds until the queue is empty.
If it helps, maybe try giving me a sample script where the afflictions I've been given are blindness, nausea and stupidity. The appropriate plant cures are as follows:
blindness: bloodroot
nausea: ginseng
stupidity: goldenseal
Any help is appreciated and I'll be more than happy to clarify any ambiguities. Thanks! |
Open the watch. | | Top |
|
| Posted by
| Stoned00d
(14 posts) Bio
|
| Date
| Reply #1 on Sun 23 Jun 2002 07:58 PM (UTC) |
| Message
| I think it was Magnum who was working on and successfully(?) built a spell queue, you could look into that although understanding how to use it might take quite a bit of scripting.
If you've already set up a trigger to toggle on/off the afflictions, all you have to do is use the DoAfter command and (with the way I'm doing it) another variable to keep track of the number of things you'll need to eat
var wait=blindness+nausea+stupidity (assuming you're toggling between true and false)
if blindess=1 then
world.doafter (6-wait*2), "eat bloodroot"
wait=wait-1
end if
if nausea=1 then
world.doafter (6-wait*2), "eat goldenseal"
wait=wait-1
end if
if stupidity=1 then
world.doafter (6-wait*2), "eat bloodroot"
wait=wait-1
end if
For a longer list you'd probably be better off using arrays. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
| Date
| Reply #2 on Tue 25 Jun 2002 01:54 AM (UTC) Amended on Tue 25 Jun 2002 01:59 AM (UTC) by Nick Gammon
|
| Message
| You can use "getvariablelist" to do that, quite simply. Try something like this:
dim value, spell, delay
delay = 2
For Each v In world.GetVariableList
value = world.GetVariable (v)
If Left (v, 11) = "affliction_" Then
spell = Mid (v, 12) ' spell is after "affliction_"
If value = "on" Then ' do if spell is active
Select Case spell
case "blindness" world.doafter delay, "eat bloodroot"
case "nausea" world.doafter delay, "eat ginseng"
case "stupidity" world.doafter delay, "eat goldenseal"
End Select
delay = delay + 2
End If ' end spell "on"
End If ' end variable starting with "affliction_"
Next
Maybe turn the affliction off afterwards? Like this:
world.setvariable v, "off"
You could do that after the line "delay = delay + 2" |
- 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.
15,165 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top