Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Alias
- --Pattern: ^setTime (\d+):(\d+) (\w+)$
- set_time(matches[2], matches[3], matches[4])
- --Timer
- if min == nil then
- min = 0;
- end
- if hr == nil then
- hr = 0;
- end
- min = min + 1;
- if min == 60 then
- min = 0;
- hr = hr + 1;
- if hr == 24 then
- hr = 0;
- end
- end
- --Script
- function set_time(shr, smin, sdot)
- local h = tonumber(shr);
- if sdot == "AM" and h == 12 then
- h = 0;
- elseif sdot == "PM" and h ~= 12 then
- h = h + 12;
- end
- hr = h;
- min = tonumber(smin);
- end
- function write_time()
- local s;
- local shr;
- local smin;
- local sdot;
- if hr < 12 then
- sdot = "am";
- else
- sdot = "pm";
- end
- if hr == 0 then
- shr = "12"
- elseif hr > 12 then
- shr = hr - 12
- else
- shr = hr
- end
- if min < 10 then
- smin = "0" .. min;
- else
- smin = min;
- end
- s = "Time is " .. shr .. ":" .. smin .. " " .. sdot;
- return s;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement