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 ➜ Timer that skips

Timer that skips

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


Posted by Demptus   (5 posts)  Bio
Date Sun 13 Apr 2003 12:14 AM (UTC)
Message
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
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #1 on Sun 13 Apr 2003 12:43 AM (UTC)

Amended on Sun 13 Apr 2003 12:45 AM (UTC) by Flannel

Message
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.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Demptus   (5 posts)  Bio
Date Reply #2 on Sun 13 Apr 2003 02:42 AM (UTC)
Message
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
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 13 Apr 2003 03:27 AM (UTC)

Amended on Sun 13 Apr 2003 03:28 AM (UTC) by Nick Gammon

Message
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


- Nick Gammon

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

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #4 on Sun 13 Apr 2003 08:44 AM (UTC)
Message
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.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
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.


16,661 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.