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

redstone.getInput vs os.pullEvent()

Started by LostContact, 09 July 2013 - 07:40 PM
LostContact #1
Posted 09 July 2013 - 09:40 PM
whats the difference and how can I use it to make my code more effective at what I want the computer to do?
Lyqyd #2
Posted 09 July 2013 - 11:27 PM
Split into new topic.

One checks the current state of a redstone input, the other waits for an event to occur.
PixelToast #3
Posted 10 July 2013 - 12:02 AM
while true do
  os.pullEvent("redstone")
  if rs.getInput("side")==true then
  -- do stuff
  else
  -- do stuff
  end
end

do something like that
ElvishJerricco #4
Posted 10 July 2013 - 01:37 AM
while true do
  os.pullEvent("redstone")
  if rs.getInput("side")==true then
  -- do stuff
  else
  -- do stuff
  end
end

do something like that

Quick pet peeve, doing

if x == true then

is pointless. If the value already is true, why resolve it to true? The only thing this accomplishes is making sure x is a boolean and it's equal to true.