Jump to content




Updating Monitor Info With No Scrolling

peripheral

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

#1 Sorcelator

  • Members
  • 24 posts

Posted 09 September 2013 - 07: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?

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 09 September 2013 - 09: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?

#3 diegodan1893

  • Members
  • 164 posts
  • LocationSpain

Posted 10 September 2013 - 05: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)


#4 Sorcelator

  • Members
  • 24 posts

Posted 12 September 2013 - 07:20 AM

View Postdiegodan1893, on 10 September 2013 - 05:01 AM, said:

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users