08.11.2021, 13:19
Scheduled script that runs every minute. Fill schedule table with dates and times.
I suppose there should be a formula for calculating times for each date. Might be easier to implement it instead of a fixed table.
Code:
schedule = {
['1/1'] = { '1:05', '2:10' },
-- ...
['12/31'] = { '1:11', '15:13' },
}
dtbl = os.date('*t')
date = string.format('%d/%d', dtbl.month, dtbl.day)
time = string.format('%d:%02d', dtbl.hour, dtbl.min)
schedtimes = schedule[ date ] or {}
for _, schedtime in ipairs(schedtimes) do
if schedtime == time then
-- execute action
end
end