Jump to content




redstone.getInput vs os.pullEvent()


  • You cannot reply to this topic
3 replies to this topic

#1 LostContact

  • New Members
  • 1 posts

Posted 09 July 2013 - 08: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?

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 09 July 2013 - 10:27 PM

Split into new topic.

One checks the current state of a redstone input, the other waits for an event to occur.

#3 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 09 July 2013 - 11:02 PM

while true do
  os.pullEvent("redstone")
  if rs.getInput("side")==true then
  -- do stuff
  else
  -- do stuff
  end
end

do something like that

#4 ElvishJerricco

  • Members
  • 803 posts

Posted 10 July 2013 - 12:37 AM

 PixelToast, on 09 July 2013 - 11:02 PM, said:

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users