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 ➜ My script probably runs to fast, how can i prevent this?

My script probably runs to fast, how can i prevent this?

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


Posted by Aerath   (8 posts)  Bio
Date Mon 11 Jul 2005 02:58 PM (UTC)
Message
Hey i have a problem with the following script:

if (world.getvariable ("Plant_balance") = 1) then
if (world.getvariable ("Paralysis") = 1) then
world.send "eat bloodroot"
end if
if (world.getvariable ("Bloodroot_eaten") = 1) then
world.setvariable "Plant_balance", "0"
world.setvariable "Bloodrootcounter", Cint(getvariable("Bloodrootcounter")) -1
if (world.getvariable ("Bloodrootcounter") = 0) then
World.send "outr 5 bloodroot"
world.setvariable "Bloodrootcounter", "5"
end if
end if
if (world.getvariable ("Bloodroot_eaten") = 1) then
if (world.getvariable ("Paralysis_cured") = 0) then
world.setvariable "Paralysis", "0"
end if
end if
if (world.getvariable ("Paralysis_cured") = 1) then
world.setvariable "Paralysis", "0"
world.setvariable "Paralysis_cured", "0"
end if
world.setvariable "Bloodroot_eaten", "0"
end if

I should add some information to it.
In mushclient i have 5 variables, Plant_balance, Paralysis,
Paralysis_cured, Bloodrootcounter and Bloodroot_eaten.
This script is checked every time with a timer that checks if conditions ae true.
This script is triggered by a trigger which for example shows on my screen that i am paralyzed.
This trigger sets the variable Paralysis on 1.
Variable Plant_balance is standard 1 on the beginning.
The script goes off, the first couple of lines go well, until the line to send eat bloodroot to world.
When this is send, an ingame trigger goes off when i eat it, setting the variable Bloodroot_eaten to 1.
then the next lines i think it skips because the script runs to fast to change and immedeately check any values of variables.
Plant_balance is set to 0 if bloodroot_eaten is 1.
Bloodroot_counter is not of importance here in my question.
Ok what this script gives is when it is triggered, it sends the eat bloodroot to the world, then after the timer checks it again it eats another, this is not what its supposed to do heh, it probably skips some lines of script since the values are not yet appointed to the variables in Mushclient itself yet..
Whats wrong here..? what i want this piece of script to do is the following:
If it triggers it must send eat bloodroot to the world, this actually works fine. Then it has to test if this really happened, if it is shown on the screen, lag and stupidity affliction can hinder this.
If this is true, make Plant_balance = 0.
If this is true check if trigger has fired saying: You muscles unlock, you are no longer paralyzed (i have that one made into mushclient), this one makes Paralysis_cured = 1
if true set variable Paralysis = 0 and Paralysis_cured = 0
If bloodroot_eaten = 1 and Paralysis_cured is not 1 it has to set Paralysis = 0.
And a last it has to check the script piece again if the bloodroot was not eaten, this has to set plant_balance = 1 and should leave Paralysis = 1 also.
I think this is pretty much how i want it to work, sorry for the complicated imformation, but i am really stuck on this one.
Can anyone help me out with this?
Alot of thanks!

Aerath, Achaean player.
Top

Posted by Caeser   (22 posts)  Bio
Date Reply #1 on Tue 12 Jul 2005 01:09 AM (UTC)
Message
I don't know much about scripting...but you could trim a lot of that down.

For instance, instead having to make a variable called "bloodroot_eaten" and checking for that on, you could just make the paralysis cure message trigger the commands to set the variable "paralysis" to 0 and have it subtract 1 from the variable "bloodrootcounter".

You would then have the message that you can eat again trigger the variable "plant_balance" to 1.

Sorry I can't post the script commands seeing as I don't know them. But logically, that should work.
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #2 on Tue 12 Jul 2005 06:34 AM (UTC)
Message
I'm not totally sure I understand your problem, but you need to realise that testing if something has happened in a script immediately after you send something to the MUD will not work. The send is queued up and will not actually be processed until the entire script ends.

So, you might add a timer that checks a second later, if the thing you are trying to do has worked.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Aerath   (8 posts)  Bio
Date Reply #3 on Tue 12 Jul 2005 10:43 PM (UTC)
Message
Thanks alot Nick, it is working now how it should be :P
I splitted the script in 2 and did a check on the second part with another timer, this way the script can process the ingame variables made by the first part.

greets Aerath.
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,884 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.