Animated timers using Geyser

Share your scripts and packages with other Mudlet users.
User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: Animated timers using Geyser

Post by demonnic »

Thanks! I'm always happy to hear the stuff I've written has been found useful by someone. =)

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: Animated timers using Geyser

Post by Caled »

Added a line (the first one) to one of the functions, to prevent errors if the timer hasn't been initialised for the first time yet:
Code: [show] | [select all] lua
function demonnic.anitimer:getTime(name)
	if not demonnic.anitimer.timers[name] then return 0 end
  local max = demonnic.anitimer.timers[name].max
  local current = getStopWatchTime(demonnic.anitimer.timers[name].watch)
  local newValue = max - current
  return newValue
end
Edit: incidentally, thanks so much for this script. I'd been trying to create my own version for years, and now that I have it, I'm using them for all sorts of things. I've got my balances, my target's balances, and various other ticks like howls/roars, all synced and stacked on top of each other in prime screen-space.

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: Animated timers using Geyser

Post by demonnic »

Glad you're finding it useful! Though really, I just found something someone else had done, dusted it off, and bolted some bits on to make it a bit easier to use.

icester
Posts: 17
Joined: Tue Jun 08, 2010 10:43 am

Re: Animated timers using Geyser

Post by icester »

Any way to make this work instead of showing the number count down, just show a word?

otherwise its pretty nice and I've put it into my imperian system :P

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: Animated timers using Geyser

Post by demonnic »

Updated with a new option for adding words to the text it shows.

it's between the showTime and css options, so if you're using css you'll need to adjust your calls if you update the code.

the code for the demo in the original post therefore becomes:
Code: [show] | [select all] lua
demonnic.newContainer = demonnic.newContainer or Geyser.Container:new({x=0, y=0, height=400, width = 200})
myCss1 = [[
border-width: 4px;
border-radius: 7;
border-color: red;
background-color: green;
]]
myCss2 = [[
border-width: 4px;
border-radius: 7;
border-color: green;
background-color: red;
]]
demonnic.anitimer:new("Test1", {x=200, y=100, height = 30, width = 300, color="red"}, 5)
demonnic.anitimer:new("Test2", {x = 0, y="50%", height = 20, width = "100%"}, 10, demonnic.newContainer, true,"Test2", myCss1, myCss2)
demonnic.anitimer:new("Test3", {x = 500, y = 300, height = 40, width = 100}, 8, "",false, "Test3", myCss2, myCss1)
demonnic.anitimer:new("Test4", {x=-20, y=0, height = 20, width = "100%"}, 18, demonnic.newContainer, false, "")

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: Animated timers using Geyser

Post by demonnic »

2 quick updates.

2.2 - adds :pause(name), and :start(name) functionality, but leaves the :new() syntax the same

3.0 - adds :pauseAll(), :stopAll(), :startAll(), :destroy(name), and :destoryAll() functions. Also rewrote the constructor to be more like my align() series of functions. This makes it easier to add options to the constructor as needed.

baerden
Posts: 21
Joined: Thu Jul 18, 2013 7:49 am

Re: Animated timers using Geyser

Post by baerden »

Hi. I'm trying to pass a variable from a trigger to the gauge and its not working.

I have a perl regex trigger to capture the number.
Code: [show] | [select all] lua
Roundtime: (\d+) seconds.
And here is the rest of the script. Its failing to initialize a timer at all. How do I pass a variable to start a timer?
Code: [show] | [select all] lua
GuageRoundtime = matches[2]


demonnic.newContainer = demonnic.newContainer or Geyser.Container:new({x=0, y=0, height=400, width = 200})
myCss1 = [[
border-width: 4px;
border-radius: 7;
border-color: red;
background-color: green;
]]
myCss2 = [[
border-width: 4px;
border-radius: 7;
border-color: green;
background-color: red;
]]

demonnic.anitimer:new("Test1", {x=0, y=1337, height = 30, width = 300, color="red"}, GuageRoundtime)

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: Animated timers using Geyser

Post by Belgarath »

You're passing a string instead of an actual number. Try changing the variable line to:
Code: [show] | [select all] lua
GaugeRoundTime = tonumber(matches[2])

baerden
Posts: 21
Joined: Thu Jul 18, 2013 7:49 am

Re: Animated timers using Geyser

Post by baerden »

Aha! That worked. I knew it had something to do with being a string but I wasn't sure how to deal with it.

Now I know, and knowing, is half the battle.

Go Joe!

Vooku
Posts: 72
Joined: Sun Aug 21, 2016 2:42 pm

Re: Animated timers using Geyser

Post by Vooku »

I'm a real nub when it comes to this stuff so please bare with me....

How would I set up a bar to activate with a sample command? For example, I would like a 90 count down bar to start when I type in command 'X".

I'm sure it's simple, I just don't know where to start.

Post Reply