290 posts
Location
St.Louis, MO
Posted 05 December 2012 - 08:19 AM
Ok so the code is
while true do
if redstone.getInput("left") then
if redstone.getOutput("right") then
redstone.setOutput("right",false)
else
redstone.setOutput("right",true)
end
end
end
when i run it it works fine but when i press the button to the left of it while the program is on my world just closes and it says Server Closing or something like that.
3790 posts
Location
Lincoln, Nebraska
Posted 05 December 2012 - 08:27 AM
Your program wouldn't do that. There must be something wrong witht he installation of your mods. Do you have any other mods?
(quick note/improvement)
while true do
local event, p1 = os.pullEvent()
if event == "redstone" and rs.getInput("left") then
if rs.getOutput("right") then
rs.setOutput("right", false)
else
rs.setOutput("right", true)
end
end
end
290 posts
Location
St.Louis, MO
Posted 05 December 2012 - 08:36 AM
Never mind i fixed it. it was doing the loop again before the redstone signal stopped. here is what worked.
while true do
if redstone.getInput("left") then
if redstone.getOutput("right") then
redstone.setOutput("right",false)
else
redstone.setOutput("right",true)
end
sleep(4)
end
sleep(0.001)
end
so yeah
818 posts
Posted 05 December 2012 - 09:33 AM
-snip-
2005 posts
Posted 05 December 2012 - 10:24 AM
Use an os.pullEvent("redstone") so that you only run this when there is actually a change in the redstone inputs. There is no reason to be running this so much faster than the world tick rate, and there is no reason to do anything if there isn't a change in the redstone inputs.
290 posts
Location
St.Louis, MO
Posted 05 December 2012 - 10:33 AM
Use an os.pullEvent("redstone") so that you only run this when there is actually a change in the redstone inputs. There is no reason to be running this so much faster than the world tick rate, and there is no reason to do anything if there isn't a change in the redstone inputs.
Cool. I never knew about that event. Thanks