Jump to content




Nonfunctional os.pullEvent and redstone code


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

#1 Graypup

  • Members
  • 90 posts

Posted 03 July 2013 - 05:02 PM

Here is some code to create a hack-switch for any energy-net or redstone stuff, basically, place when there's redstone, break when there isn't. I just want to know why the broken code is, well, broken.
This works:
if redstone.getInput("back") then
  turtle.place()
  else
	turtle.dig()
end
while true do
  if os.pullEvent() then
	if redstone.getInput("back") then
	  turtle.place()
	  else
	  turtle.dig()
	end
  end
end
This doesn't work:
while true do
  local msg, p1, p2 = os.pullEvent()

	rsstate = rs.getInput("back")
	--debug: comment me out:
	print(rsstate)
	if rsstate == true then
	  turtle.place()
	  elseif rsstate == false then
		turtle.dig()
	  else
		error("MY REDSTONE STATE ISNT A BOOLEAN!!!1!!")
	end

end


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 03 July 2013 - 05:56 PM

What's the print outputting?

#3 Graypup

  • Members
  • 90 posts

Posted 03 July 2013 - 05:58 PM

View PostLyqyd, on 03 July 2013 - 05:56 PM, said:

What's the print outputting?
Supposedly if the redstone is on or off. AFAIK it worked.

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 03 July 2013 - 08:25 PM

No, not what it supposedly outputs, what it actually outputs when the code is run and the redstone state changed.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users