This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
raxteeze's profile picture

How to show clock?

Started by raxteeze, 11 June 2015 - 12:26 PM
raxteeze #1
Posted 11 June 2015 - 02:26 PM
This is a function of the desktop. It should instead show signs CLOCK playing time.
playing time.


function DESKTOP()
while true do
term.setTextColor(1)
term.setBackgroundColor(1)
term.clear()

paintutils.drawPixel(1, 1, colors.red)
paintutils.drawLine(1, 1, 51, 1, colors.red)
paintutils.drawLine(1, 19, 51, 19, colors.red)

paintutils.drawLine(2, 1, 4, 1, colors.gray)
term.setCursorPos(2,1)
term.write('EOS')

paintutils.drawLine(46, 1, 50, 1, colors.gray)
term.setCursorPos(46,1)
term.write( CLOCK )

local event, button, xPos, yPos = os.pullEvent("mouse_click")

if xPos == 2 and yPos == 1 then
menu()
elseif xPos == 3 and yPos == 1 then
menu()
elseif xPos == 4 and yPos == 1 then
menu()
end
end
end


I wrote instead CLOCK
textutils.formatTime (os.time (), false
, but the time is updated only when the mouse button is pressed.
Help, please :)/>
KingofGamesYami #2
Posted 11 June 2015 - 04:10 PM
Of course the clock is only updated when someone clicks - your loop always pauses and asks for a mouse_click event. Here's a hint: never, ever, ever use event filters. Another hint: check out os.startTimer.