Posted 16 June 2014 - 02:40 AM
This time code I am trying to make is supposed to display the time of day (numerical and in words) along with the day number.
It should show up on a monitor like so:
Here is the code in its entirety:
It should show up on a monitor like so:
It is MORNING
7:00 AM
Day 1
However, upon running the code I see this: Spoiler
local mon = peripheral.wrap("right") --Define monitor
if not mon then
print("No monitor found! :(/>/>") --Monitor failsafe
end
while true do --Finds time and day every 5 seconds
local t = os.time()
local d = os.day()
sleep(5)
end
local day = "" --Creates day, a string
if t > 0 and t < 11 then --midnight to 11 AM
day = "MORNING"
elseif t > 11 and t < 13 then --11 AM to 1 PM
day = "NOON"
elseif t > 13 and t < 18 then --1 PM to 6 PM
day = "AFTERNOON"
else --any other time
day = "NIGHT"
end
while true do
print(t) --puts raw time in terminal for troubleshooting
mon.clear()
mon.setTextScale(4)
mon.setCursorPos(1, 2)
mon.write("It is " .. day)
mon.setCursorPos(4, 3)
mon.write(textutils.formatTime(t, false))
mon.setCursorPos(1, 4)
mon.write("Day " .. d)
sleep(1)
end