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

[SOLVED] Drawing on a monitor when redstone is active

Started by mpolder, 17 April 2014 - 02:54 PM
mpolder #1
Posted 17 April 2014 - 04:54 PM
im trying to create a warning for my forcefield when it is on (because it pretty much insta kills everyone)
and it is not working, the code i am using is this:


monitor = peripheral.wrap("top")
i = 1
repeat
  monitor.clear()
  i = i + 1
  if redstone.getInput("back",true) then
    monitor.write("Forcefield is ON!")
  else
    monitor.write('Forcefield is OFF!")
  end
  if i == 99 then
    os.reboot()
  end
until i == 100

this is the first time im using this in a VERY long time so i dont see any problems with it…

Hope anyone can help :)/>/>
Edited on 17 April 2014 - 03:44 PM
Lyqyd #2
Posted 17 April 2014 - 05:06 PM
You should use an actual infinite loop, and only change the message when the redstone input changes:


local mon = peripheral.wrap("top")

while true do --# actual infinite loop
  mon.clear()
  mon.setCursorPos(1,1)
  if rs.getInput("back") then --# no true parameter required
    mon.write("Field ON")
  else
    mon.write("Field OFF")
  end
  os.pullEvent("redstone") --# wait for change in input signal.
end
mpolder #3
Posted 17 April 2014 - 05:35 PM
Okay I will try it, reporting back in a sec

It works :)/>/> thanks