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

[Question] How do I make a computer print to monitor on RS input?

Started by Hypperzz22, 29 June 2012 - 11:53 AM
Hypperzz22 #1
Posted 29 June 2012 - 01:53 PM
Hey guys this is my first post, but, how do I get a computer to slow print to a monitor when it receives an input pulse from the back? Thanks.
tfoote #2
Posted 29 June 2012 - 04:35 PM

local event, param1 = os.pullEvent("redstone")
textutils.slowPrint( text )
-- you can use textutils.slowWrite( text ) also.

API's Used:
os
Textutils
MysticT #3
Posted 29 June 2012 - 04:44 PM

local monitorSide = "left" -- the side the monitor is on
local inputSide = "back" -- the side of the redstone signal

-- check if the monitor is present
if peripheral.isPresent(monitorSide) and peripheral.getType(monitorSide) == "monitor" then
  -- redirect output to the monitor
  term.redirect(peripheral.wrap(monitorSide))
else
  -- monitor not found, exit the program
  print("Monitor not found")
  return
end

while true do
  -- wait for change in redstone input
  os.pullEvent("redstone")
  -- check if the correct input is on
  if rs.getInput(inputSide) then
    -- print the text
    textutils.slowPrint("TEXT HERE")
    break -- stop the program after showing the text
  end
end

-- restore output to the terminal
term.restore()
Hypperzz22 #4
Posted 30 June 2012 - 12:19 AM
Thanks guys, this worked perfectly! =D