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

Updating Monitor Info With No Scrolling

Started by Sorcelator, 09 September 2013 - 06:24 PM
Sorcelator #1
Posted 09 September 2013 - 08:24 PM
Hey guys. I've been playing around with open.peripheral recently and I wanted to create a simple program that outputs the max capacity of a batbox and displays how much of that capacity is being used. this is what I have so far.


while true do
os.startTimer(5)
os.pullEvent("timer")
local bat1cap = net.callRemote("batbox_3","getCapacity")
local bat2cap = net.callRemote("batbox_4","getCapacity")
local bat1store = net.callRemote("batbox_3","getStored")
local bat2store = net.callRemote("batbox_4","getStored")
print("BatBox [1] Power Levels")
print(bat1store.."/"..bat1cap)
print("")
print("BatBox [2] Power Levels")
print(bat2store.."/"..bat2cap)
end

however. When I go to display this on my monitor the text obviously scrolls up as the new lines are being printed.
I tried doing this


while true do
shell.run('clear')
os.startTimer(5)
os.pullEvent("timer")
local bat1cap = net.callRemote("batbox_3","getCapacity")
local bat2cap = net.callRemote("batbox_4","getCapacity")
local bat1store = net.callRemote("batbox_3","getStored")
local bat2store = net.callRemote("batbox_4","getStored")
print("BatBox [1] Power Levels")
print(bat1store.."/"..bat1cap)
print("")
print("BatBox [2] Power Levels")
print(bat2store.."/"..bat2cap)
end

but the result is that the screen stays blank.
Any suggestions?
Lyqyd #2
Posted 09 September 2013 - 10:26 PM
If you clear the screen, wait five seconds, write a bunch of stuff to the screen, clear the screen, wait five seconds, etc., when will people be able to read what's on the screen?
diegodan1893 #3
Posted 10 September 2013 - 06:01 AM
You need to clear the screen after waiting 5 seconds, not before.

Also,

os.startTimer(5)
os.pullEvent("timer")
is the same as:

sleep(5)
Sorcelator #4
Posted 12 September 2013 - 08:20 AM
You need to clear the screen after waiting 5 seconds, not before.

Also,

os.startTimer(5)
os.pullEvent("timer")
is the same as:

sleep(5)

Ooooooh… this is why I shouldn't code when I'm sleepy.