So I've made a program to turn off the rain using the rainmaker from forestry. I run my program, but my turtle does not appear to care that the turtle.detect() is false. It's clearly something wrong with my program. Could I get some advice as to how to fix the problem?
Thanks!!!
The goal of this program is to get it to check for a block, and if there is one, then give the rainmaker a dissipation charge, which it contains in its inventory.
local x
x = 0
while x<9 do
turtle.detect()
if true then turtle.turnRight()
turtle.turnRight()
turtle.drop(1)
sleep(19)
turtle.turnRight()
turtle.turnRight()
if false then sleep(5)
end
end
end
Rain Program
Started by SullyPlayer, Jul 02 2014 06:31 PM
3 replies to this topic
#1
Posted 02 July 2014 - 06:31 PM
#2
Posted 02 July 2014 - 06:54 PM
Here:
for x=1,9 do
if turtle.detect() then
turtle.turnRight()
turtle.turnRight()
turtle.drop(1)
sleep(19)
turtle.turnRight()
turtle.turnRight()
else
sleep(5)
end
end
#3
Posted 02 July 2014 - 06:58 PM
local x x = 0 while x<9 do turtle.detect() --#you are not storing the return if true then turtle.turnRight() --#true is always true... turtle.turnRight() turtle.drop(1) sleep(19) turtle.turnRight() turtle.turnRight() if false then sleep(5) --#false is always false... end end end
Fixed the formatting for you, it's quite obvious what's wrong here.
for i = 1, 9 do --#for loops automatically increment local block = turtle.detect() --#you are not storing the return if block then turtle.turnRight() turtle.turnRight() turtle.drop(1) sleep(19) turtle.turnRight() turtle.turnRight() elseif not block then --# not simply inverts the value. false becomes true, true becomes false. sleep(5) end end endNinja'd by Assossa, but I've got a bit more explanation then he does.
Edit: fixed my code tags
Edited by KingofGamesYami, 02 July 2014 - 06:59 PM.
#4
Posted 02 July 2014 - 07:25 PM
That isn't quite what I wanted. I want it to keep checking for the rain until it occurs, so that when it does, it turns off the rain and then starts checking again. I'm using a rain sensor from project red to send a redstone signal to my piston forcing a block down for the turtle to detect.
Sorry!
Sorry!
Edited by SullyPlayer, 02 July 2014 - 07:29 PM.
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











