This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Creating a script that use a database or array
#6
Scheduled script that runs every minute. Fill schedule table with dates and times.
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
I suppose there should be a formula for calculating times for each date. Might be easier to implement it instead of a fixed table.
Reply


Messages In This Thread
RE: Creating a script that use a database or array - by admin - 08.11.2021, 13:19

Forum Jump: