Jump to content




[Answered] Need help with clock


  • You cannot reply to this topic
7 replies to this topic

#1 ExtraRandom

  • Members
  • 17 posts

Posted 01 September 2012 - 10:04 PM

Hi there, I am making a Clock (Minecraft in game time not real life) for my server and i have a way to find the time and printing it but i want it to replace what it wrote instead of writing more and more, i hope this makes sense.

heres the code if you need it

function infiniteLoop()
while true do

local time = os.time()
time = textutils.formatTime(time, false)
print(time)
sleep(0.8)

end
end

infiniteLoop()


#2 Xhisor

  • New Members
  • 37 posts
  • LocationSweden

Posted 01 September 2012 - 10:07 PM

View PostExtraRandom, on 01 September 2012 - 10:04 PM, said:

Hi there, I am making a Clock (Minecraft in game time not real life) for my server and i have a way to find the time and printing it but i want it to replace what it wrote instead of writing more and more, i hope this makes sense.

heres the code if you need it

function infiniteLoop()
while true do

local time = os.time()
time = textutils.formatTime(time, false)
print(time)
sleep(0.8)

end
end

infiniteLoop()
function infiniteLoop()
while true do
local time = os.time()
time = textutils.formatTime(time, false)
term.clear()
term.setCursorPos(1,1)
print(time)
sleep(0.8)
end
end
infiniteLoop()
There you go!

#3 Matrixmage

  • Members
  • 116 posts
  • LocationAt my Computer coding for the Computer in my Computer

Posted 01 September 2012 - 10:08 PM

add "term.clear" to clear the screen

Edit: ninja'd xD

#4 Xhisor

  • New Members
  • 37 posts
  • LocationSweden

Posted 01 September 2012 - 10:09 PM

View PostMatrixmage, on 01 September 2012 - 10:08 PM, said:

add "term.clear" to clear the screen

Edit: ninja'd xD
MOHAHAHAHAHAHA! :)/>

#5 ExtraRandom

  • Members
  • 17 posts

Posted 01 September 2012 - 10:13 PM

oh thanks lol forgot about term.clear

#6 jaytime104

  • New Members
  • 11 posts
  • Locationdallas tx

Posted 02 September 2012 - 04:22 PM

ok this program is sweet but can u make it to where itll scale wit my monitors the monitors are on top of my computer please help

#7 Flipsanta

  • New Members
  • 3 posts

Posted 15 December 2012 - 11:54 PM

Hello
i am new to computer craft and i dont know why this code is not working for me.
i wrote that into a program called "clock" and got my monitor on the right, so i use th command:"monitor right clock" and then this error comes on the monitor: "textutils:30: attempt to compare function with number"
plz help me :D


function infiniteLoop()
while true do
local time = os.time()
time = textutils.formatTime(time, false)
term.clear()
term.setCursorPos(1,1)
print(time)
sleep(0.8)
end
end
infiniteLoop()

#8 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 16 December 2012 - 12:40 AM

View PostFlipsanta, on 15 December 2012 - 11:54 PM, said:

Hello
i am new to computer craft and i dont know why this code is not working for me.
i wrote that into a program called "clock" and got my monitor on the right, so i use th command:"monitor right clock" and then this error comes on the monitor: "textutils:30: attempt to compare function with number"
plz help me :D


function infiniteLoop()
while true do
local time = os.time()
time = textutils.formatTime(time, false)
term.clear()
term.setCursorPos(1,1)
print(time)
sleep(0.8)
end
end
infiniteLoop()

just try replacing term. with monitor. and running like normal. if that doesnt work add this to the front

mon = peripheral.wrap("right")

then replace all the term. with mon.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users