initial commit with all the stuff

This commit is contained in:
2025-11-23 13:27:23 +01:00
parent 3f7069b328
commit 1c8a143e7a
5241 changed files with 986176 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
local scheduler = {}
socket = require('socket')
function scheduler.Timer(init)
-- the new instance
local self = {
-- public fields go in the instance table
interval = init
}
local function millis()
return socket.gettime()*1000
end
-- private fields are implemented using locals
-- they are faster than table access, and are truly private,
-- so the code that uses your class can't get them
local _timestamp = millis()
local _running = true
function self.elapsed()
if _running and (millis() - _timestamp ) >= self.interval then
_running = false
return true
else
return false
end
end
function self.running()
return (millis() - _timestamp ) < self.interval
end
function self.restart()
_timestamp = millis()
_running = true
end
function self.count()
return millis() - timestamp
end
-- return the instance
return self
end
return scheduler