Posted 03 July 2013 - 06: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:
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