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

[Lua] rs.getInput not working?

Started by xilyflob, 01 August 2012 - 06:45 AM
xilyflob #1
Posted 01 August 2012 - 08:45 AM
Ok. So what i am trying to do is have a program that will stop a user from opening the door to a Industrial Craft 2 nuclear reactor during its cool down phase of about 8 min, using Red Power I was able to get a signal to be outputted during that time, hitting the block to the left of the computer (door is on the right). The problem is that no matter if the input is on or not, it thinks it is on (aka. redstone is off, lets you in fine AND redstone is on, and it STILL lets you in no problem). Ive been though a couple tutorials and I cant seem to find anything that helped me. Any help is appreciated! And i realize that my code may be a bit of a mess, if there is something that is redundent or extra or whatever help with it is appreciated!

local Input1 = "Override"
local Overpass = "Inferno"
os.pullEvent = os.pullEventRaw
textutils.slowPrint("Welcome to Main Reactor Control Port 132.")
sleep(2)
term.clear()
term.setCursorPos(1,1)
if rs.getInput("left", false) then
 textutils.slowPrint("Reactor stable. Entrance granted.")
 rs.setOutput("right", true)
 sleep(10)
 rs.setOutput("right", false)
 os.reboot()
end
if rs.getInput("left", true) then
 rs.setOutput("right", false)
 textutils.slowPrint("The Reactor is in a cooldown state, please wait a maximum of 8 miniutes to complete the cycle.")
 local input = read()
 if input == Input1 then
  sleep(1)
  term.clear()
  term.setCursorPos(1,1)
  textutils.slowPrint("Please enter override pasword.")
  local input = read()
  if input == Overpass then
   sleep(1)
   term.clear()
   term.setCursorPos(1,1)
   textutils.slowPrint("Accepted. Enter.")
   rs.setOutput("right", true)
   sleep(2)
   term.clear()
   term.setCursorPos(1,1)
   sleep(8)
   rs.setOutput("right", false)
  else
   sleep(2)
   print("Incorrect. Please try again. In the event of an emergency permision is granted to break outer door.")
  end
os.reboot()
end
end
Kolpa #2
Posted 01 August 2012 - 09:54 AM
i dont know if
rs.getInput("side",false)
is possible,
try using this for redstone off
 if rs.getInput("left") == false then
and this for redstone on
 if rs.getInput("left") == true then
Noodle #3
Posted 01 August 2012 - 04:21 PM
if rs.getInput("left") then
You don't need the "== true".
xilyflob #4
Posted 01 August 2012 - 06:42 PM
Thanks Kolpa! I did it as such becuase the wiki said so….but your solution fixed it! Thanks again!
Kolpa #5
Posted 01 August 2012 - 11:10 PM
if rs.getInput("left") then
You don't need the "== true".

i know that i was just trying to make it as not confusing as possible
Luanub #6
Posted 02 August 2012 - 03:54 AM
For future reference to check it if is not on you can also do


if not rs.getInput("left") then