Timer that skips

Posted by Demptus on Sun 13 Apr 2003 12:14 AM — 5 posts, 16,946 views.

#0
Hello again :)
On the mud that I play there is an item that basically sends an announcement to the player, telling him/her that 30 seconds have past by. Also on the mud that I play, every 60 seconds you are allowed to drink a special liquid that refreshes your mana.
What most people do is they set up a trigger that searches for announcement, and then drinks from the liquid. The problem with this is that because you can only drink every 60 seconds, the first announcement (indicating 30 seconds) is just a spammy useless action of your trigger going off and not actually being able to drink anything.
I'm looking make a script that triggers off of the 2nd announcement (indicating that 60 seconds has passed) rather than the 1st announcement.
And what I have so far isn't working:

First of all, I have a trigger that sets a variable whenever the timer goes off, in this case I call it "on". Then I have the below in my script


sub checkhourglass (name, line, wildcards)
dim varset
varset = world.GetVariable ("on")
if Not IsEmpty (varset) then
world.DeleteVariable "on"
world.send "get chalice pouch;drink chalice;fill chalice barrel"
End if
end sub

My idea is that when the trigger sets the variable, then the above would first check to see if the variable exists, it deletes the variable, and then preforms the necessary actions.
But it doesn't work. Can anyone suggest where I'm going wrong or if there's even an easier way to do this?
Thanks much,
Demptus
USA #1
You could just have the trigger execute a script, which increments the variable, and then checks to see if it's two... if it is, it sets it back to zero, and drinks...

something like this:

sub checkhourglass (sName, sLine, aryWld)
dim count
count = Cint(world.getvariable("DrinkTimer"))
count = count + 1
if count = 2 then 'this might end up needing to be count = "2" but Im not certain...
'If it messes up, change it (or add a Cint(count))
world.send "get chalice pouch 'all your send stuff
world.send "drink chalice"
world.send "fill chalice barrel"
world.setvariable "count", "0"
End If
end Sub


What this would do is:
First time, (after you last drank), count is 0, it adds one to make it one, checks count (which is now 1) its not 2, so it ends..

Next time, adds one, its 2, so it executes the commands, then resets count to 0, and ends.
Amended on Sun 13 Apr 2003 12:45 AM by Flannel
#2
Thanks a ton Flannel for the script,
I had a bit of trouble with it at first, mainly I think because the count variable was rewriting itself twice so it would never reset and go into the if statement and the reset itself was reseting "Count" rather than "DrinkTimer"
So here's the code now:

sub checkhourglass (sName, sLine, aryWld)
dim count
dim count2
count = Cint(world.getvariable("DrinkTimer"))
count2 = count + 1
world.setvariable "DrinkTimer", count2
if count = "2" then
world.send "get chalice pouch"
world.send "drink chalice"
world.send "fill chalice barrel"
world.setvariable "DrinkTimer", "1"
End If
end Sub

and it works exactly like I want it to. Thanks again Flannel
-Demptus
Australia Forum Administrator #3
Quote:


sub checkhourglass (sName, sLine, aryWld)
dim count
count = Cint(world.getvariable("DrinkTimer"))
count = count + 1
if count = 2 then 'this might end up needing to be count = "2" but Im not certain...
'If it messes up, change it (or add a Cint(count))
world.send "get chalice pouch 'all your send stuff
world.send "drink chalice"
world.send "fill chalice barrel"
world.setvariable "count", "0"
End If
end Sub



You are setting the wrong variable here, but it looks like Demptus has worked that out. :)

I would have done:


sub checkhourglass (sName, sLine, aryWld)
dim count
  count = Cint(world.getvariable("DrinkTimer"))
  count = count + 1
  if count >= 2 then 
    world.send "get chalice pouch" 'all your send stuff
    world.send "drink chalice"
    world.send "fill chalice barrel"
    count = 0
  End If
  world.setvariable "DrinkTimer", count
end Sub

Amended on Sun 13 Apr 2003 03:28 AM by Nick Gammon
USA #4
Knew I shouldnt have attempted to do the code itself while on pain meds for wisdom teeth...

I got the point across though, thats the important part.