How would I add a simple timer based on a trigger?

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

How would I add a simple timer based on a trigger?

Post by Vooku »

In the mud I play there is a cooldown period before you can use melee / ranged powers when swapping from one to the other. How would I add this? I'm guessing it's pretty simple, I just can't get it to work.

The triggering text would be some thing like "You wield blahblahblah axe|sword|longsword|dagger|waraxe." (for swapping to melee) and something like "You wield blahblahblah bow|longbow|warbow." (for swapping to ranged).

Just simple text number that I could place in a good location (lower left) would be great. Thanks much!

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

Re: How would I add a simple timer based on a trigger?

Post by Belgarath »

I'm not great with UI, but a simpler approach would be to use tempTimer and echo the go-ahead to the screen, like so:
Code: [show] | [select all] lua
local cooldown = 5 -- in seconds
if swapTimer then killTimer(swapTimer) end
swapTimer = tempTimer(cooldown, [[cecho('<green>Cooldown finished!\n')]])

Post Reply