PDA

View Full Version : Water Elemental Timer?


Zombic
22-07-2007, 11:10 AM
Hey Folks,

I'm a mage and I've been trying to write a little addon which will display the time remaining on my Water Elemental.

I've never really written much code before but I think I'm fairly close, I just have 2 questions I'm hoping to find answers to.

1: How do I show the frame when the Water Elemental is present and hide it again when it despawns?
I'm getting the remaining time on the water elemental using GetPetTimeRemaining() which returns secs/millisecs in the format xxxxx eg: 42317 being 42 secs, 317 millisecs. I've tried having an if function showing the frame when between 50000 and 0 but it doesn't seem to work? The countdown either stops at some very small amount like 214 or an absurdly large amount (3412341235) - either of which remains on screen permanently. ie: It's not hiding itself once the amount is outside my if variables.
This is the real sticking point: Having random numbers remaining on the screen makes the mod not worth using. Can anyone suggest a functional method for showing/hiding?

2. This is a lot less important, but while I'm asking...
As mentioned above I have 5 figures coming from GetPetTimeRemaining(). I'd like to prune these back so it only shows the second until it's less than ten, and then shows the first millisecond. So basically make it a 2 digit number.
Any ideas? Best I've been able to do is to divide the original number by 1000 to get seconds with 3 millisecond places.

Any help would be greatly appreciated!

Thanks,

Z