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

[Lua][Question] How to clear monitor text (RESOLVED)

Started by DeviousD, 07 April 2012 - 12:02 PM
DeviousD #1
Posted 07 April 2012 - 02:02 PM
I am trying to make some sort of base alert. For this I would like to have a monitor giving the current status. (all ok/Alert/etc)
I am new to lua and afther following some tutorials and trying out some code I ended with the following code.
Currently this works without problems. I would like to have the letters ALERT flicker on the screen (to draw more attention)


m = peripheral.wrap("right") --sets m as the monitor
while true do
if redstone.testBundledInput("bottom", colors.magenta) == true --checks magenta redwire
then -				--shows alert in caps when redwire is active
  m.setCursorPos(1,1)
  m.setTextScale(3)
  m.write("ALERT")
  sleep(1)

else				  -- shows all ok in caps when redwire is inactive
  m.setCursorPos(1,1)
  m.setTextScale(2)
  m.write("ALL OK")
  sleep(1)
end
end

though when I try to delete/clear the text ALERT afther the 1 second sleep nothing happens. I have tried using
m.clear()
m.setCursorPos(1,1)

And I have tried using the clearline command
m.clearline()

Neither of those worked could someone please explain to me how to clear text on a monitor?

thanks,
DeviousD
Cloudy #2
Posted 07 April 2012 - 02:55 PM
Your issue is as soon as you clear, it will go back to the beginning of the script and write the ALERT again. Add a sleep after the clear.
DeviousD #3
Posted 07 April 2012 - 02:59 PM
Thanks :P/>/> it works perfectly now.