Posted 30 November 2013 - 06:07 PM
Hi everyone
I have written a program which is for use terminal glasses to show ingame time.
All works fine exept of one thing: I'm not able to return the chat_command at the end of the program to change format or exit.
Please help!
Sorry for bad english ;)/>
I have written a program which is for use terminal glasses to show ingame time.
All works fine exept of one thing: I'm not able to return the chat_command at the end of the program to change format or exit.
Please help!
Sorry for bad english ;)/>
glass = peripheral.wrap("right")
glass.clear()
timeFormat = true
function sleeping()
while true do
event, command = os.pullEvent("chat_command")
if command == "start" then
break
end
end
end
function openAnimation()
Xsize = 0
Ysize = 3
while Xsize < 100 or Ysize < 45 do
glass.clear()
glass.addBox(6, 6, Xsize, Ysize, 0xFFFFFF, 0.5)
if Xsize < 100 then
Xsize = Xsize + 10
elseif Ysize < 100 then
Ysize = Ysize + 10
end
sleep(0.01)
end
glass.clear()
end
function backGround()
backgroundbox = glass.addBox(6, 6, 100, 45, 0xFFFFFF, 0.5)
end
function showTime(format)
clockWidth = 74
while true do
glass.clear()
backGround()
clock = textutils.formatTime(os.time(), format)
day = os.day()
dayText = glass.addText(8, 8, "Day: "..day, 0x3366FF)
dayText.setZIndex(2)
clockText = glass.addText((56 - clockWidth / 2), 20, clock, 0x33CCFF)
clockText.setScale(3)
clockWidth = clockText.getWidth()
clockText.setZIndex(2)
sleep(0.1)
os.queueEvent("event_marker")
local breakOut = false
while true do
e, command2 = os.pullEvent()
if e == "chat_command" then
breakOut = true
elseif e == "event_marker" then
break
end
end
if breakOut == true then
break
end
end
return command2
end
sleeping()
openAnimation()
backGround()
sleep(0.3)
while true do
command2 = showTime(timeFormat)
if command2 == "format" then
if timeFormat == true then
timeFormat = false
else
timeFormat = true
end
elseif command2 == "exit" then
break
end
end