Doh, sorry about my previous post on this thread.
Basically I don't say
dim herbbalance
Sub Eat_herb (a,b,c)
World.Send "eat herb"
herbbalance = 0
End Sub
I do:
dim herbbalance ' Variable
Sub herbbalance_on (a,b,c) ' Sub to turn herbbalance on
herbbalance = 1
End Sub
Sub herbbalance_off (a,b,c) ' Sub to turn herbbalance off
herbbalance = 0 ' Called on the trigger:
End Sub ' ^You have eaten an herb\.$
Sub Eat_herb (a,b,c) ' Sub to eat an herb
If herbbalance = 1 then
World.Send "eat herb"
End If
End Sub
That's how it do it currently, and er, to simplify (not exactly how I do it, but for simplicity's sake) things I call eat_herb on balance/eq/etc.
So, if I get balance and eq simultaneously, I do eat_herb twice, and I overeat.
Now, if there were millisecond interval timers, I could do..
<timers>
<timer name="anti_double_eat" script="imaginary_herbbalance_on" second=".3" >
</timer>
</timers>
dim herbbalance ' Variable
dim fake_herbbalance
Sub herbbalance_on (a,b,c) ' Sub to turn herbbalance on
herbbalance = 1
End Sub
Sub herbbalance_off (a,b,c) ' Sub to turn herbbalance off
herbbalance = 0 ' Called on the trigger:
End Sub ' ^You have eaten an herb\.$
Sub imaginary_herbbalance_on (a,b,c)
fake_herbbalance = 1
End Sub
Sub Eat_herb (a,b,c) ' Sub to eat an herb
If fake_herbbalance = 1 AND herbbalance = 1 then
World.Send "eat herb"
fake_herbbalance = 0
World.EnableTimer "anti_double_eat", 1
End If
End Sub
If I did it that way, then the fake balance variable would be turned to false, then be turned on 300 milliseconds later, enough so that I don't double eat on the chance that I call this sub twice. |