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

Posted by Aerath on Mon 11 Jul 2005 02:58 PM — 4 posts, 17,602 views.

#0
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.
#1
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.
Australia Forum Administrator #2
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.
#3
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.