I made a Timer

I develop a timer so anyone can use it in his games


Initialization

First, you have to copy-paste this class:

Timer = class
  timer = 0
  paused = false
  
  constructor = function(medid, start = 0)
    this.medid = medid
    this.start = start
  end
  
  init = function()
    timer = this.start
  end
  
  update = function()
    if paused != true then
      timer += 1/this.medid
    end
  end
  
  restart = function()
    timer = this.start
  end
end

Then you will have to make an instance of the timer using name_of_timer = new Timer(20, 0)

Information for the parameters:

The first parameter is the medid. Is the divide number of the time.

The second parameter is the start. Which instance will start. For default is Zero


Usage.

When you initialize a timer, you have to do this requirements:

init = function()
  time_example = new Timer(60)
  time_example.init()
  ...
end

update = function()
  time_example.update()
  ...
end

...

Now you're done! You have a working timer! There is more: If you want to get the timer use time_example.timer and if you wan't to pause it use time_example.paused = true

I will improve the timer while time pass. I hope this help you!