Temp Timer?

Post Reply
Skriptz
Posts: 45
Joined: Sun Dec 27, 2009 10:48 pm

Temp Timer?

Post by Skriptz »

Okay so I'm working on my defence system and I'm needing to add a timer since if something happens unforeseen my variable won't change and so I'm sitting with a variable not changing back to true, or false depending on the situation.

I tried to read the manual on the subject but I still have no idea on about it and I can't seem to find about temp timers with Lua so I'm guessing it's unique to Mudlet?

Anyway my problem is I'm making a autosipper (and herb eater, salve applier etc). I got everything working perfectly except a few times where I get stunned and messes me up. Here's part of the code I have now, which isn't working.

Code: Select all

if (CurrentHealth < SipHealth)
	and (CurrentHealth > 0)
	and GotElixirBal==1 then 
      send("sip health")
		GotElixirBal = 0.5
	tempTimer( 0.6, [
	if GotElixirBal = 0.5 then GotElixirBal = 1]] )
What I want it to do is that is my current health is lower than the predefined sip health and I got balance to sip health AND I'm not dead then sip health and send 0.5 variable which then I will have a trigger saying if I was successful then change it to 0 but if I was stunned, or sleep or blacked out etc then it will stay as that.

The temptimer goes for 6 seconds which Elixir balance is only 5 seconds but just incase of lag. If something goes wrong and after that 6 seconds it will change it back to me having Elixir balance so I can start sipping health again.

So my question is, how do set it up so that when send the command to sip but nothing happens (possibly due to a illusion?) that it can reset. Also will it reset after I get balance back? So if I sipped and everything worked as planned and I sipped again right on 5 seconds which gives me 1 second left and I sip again, will it reset my sipping balance to true? Even though I regained it and used it again?

I hope that makes sense.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Temp Timer?

Post by Vadi »

tempTimer( 0.6, [
if GotElixirBal = 0.5 then GotElixirBal = 1]] )

a) you're making a timer for 0.6 seconds. not 6, but 0.6
b) you forgot an end to the if!

tempTimer( 6, [
if GotElixirBal = 0.5 then GotElixirBal = 1 end echo("yay I work!")]] )

Skriptz
Posts: 45
Joined: Sun Dec 27, 2009 10:48 pm

Re: Temp Timer?

Post by Skriptz »

Vadi wrote:tempTimer( 0.6, [
if GotElixirBal = 0.5 then GotElixirBal = 1]] )

a) you're making a timer for 0.6 seconds. not 6, but 0.6
b) you forgot an end to the if!

tempTimer( 6, [
if GotElixirBal = 0.5 then GotElixirBal = 1 end echo("yay I work!")]] )
Doesn't work. It says Image

So I deleted the extra ] but still nothing. Anyway I'll show a bit more of the code to show the end.

Code: Select all

if (CurrentHealth < SipHealth)
	and (CurrentHealth > 0)
	and GotElixirBal==1 then 
      send("sip health")
		GotElixirBal = 0.5
	tempTimer( 6, [
if GotElixirBal = 0.5 then GotElixirBal = 1 end echo("yay I work!")] )

elseif
	(CurrentHealth > SipHealth)
	and (CurrentHealth > 0)
	and GotElixirBal==1 
	and (CurrentMana < SipMana) then
		send("sip mana")
		GotElixirBal = 0
end

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Temp Timer?

Post by Vadi »

Should be two [[]] at beginning and end

Skriptz
Posts: 45
Joined: Sun Dec 27, 2009 10:48 pm

Re: Temp Timer?

Post by Skriptz »

Okay I'm almost at the point of giving up. I have decided to forget about it but then I need it for herb cures so I gotta do it.

It doesn't seem to be working. I'm thinking it won't register a if statement in the temp timer. I got the echo to work by itself but not when the if statement and variables are in it. Has anyone else got it to work and willing to share? Or am I trying to make it to advanced?

To make it a little more understandable I'm looking at a tutorial which has this, just need to change it to mudlet.

Code: Select all

"ginseng" ->
outr ginseng
eat ginseng
herbbalance=0.5
#alarm +2 {#if @herbbalance="0.5" {herbbalance=1}}
Edit: I'm looking for solutions and found a post a few months back stating that functions don't work in the tempTimers? Anyway I tried working around it by making my own function but the if statements won't work inside a created function so either I'm doing if statements wrong which I shouldn't be as I got a few working or it's not yet built in?

Iocun
Posts: 174
Joined: Wed Dec 02, 2009 1:45 am

Re: Temp Timer?

Post by Iocun »

The Mudlet equivalent to this zMud timer looks like this:

tempTimer( 6, [[if GotElixirBalance==0.5 then GotElixirBalance=1 end]] )

Take note of the double [[ and ]], as Vadi noted. These make the second argument of tempTimer into a string. (You could use quotation marks as well.)
Also take note of the "==" in the "if" comparison, vs. the single "=" in the "then" block. A single = is used to set a variable. Double == are used to compare values.

Skriptz
Posts: 45
Joined: Sun Dec 27, 2009 10:48 pm

Re: Temp Timer?

Post by Skriptz »

Ahh and I was just about to post a work around too. I got it working by making a timer and using the commands enableTimer and disableTimer but you got it to work. Thanks very much. My system is getting better every moment.

Post Reply