Posted 03 August 2014 - 10:18 PM
So after finally getting my planting turtle to plant the entire field. A friend hopped by to look at it and jumped infront of the turtle thus mixing up it's entire planned out route. very dissapointing to say the least xD.
Now i have been trying to make a small sort of detect system that keeps up forward movement. Tested it as a single script in which it worked excellent. If i stand infront of it it waits till it can move forward and if i put a block there it digs it away.
Now when i implement this as a funtion into the code however like this it seems to completely ignore it. I have the feeling i'm overlooking something. Tried all day to find out way this happens without simply copy pasting codes (since i do want to understand what i'm doing atleast if it works :)/>. Could somebody explain why this is happening ?
Now i have been trying to make a small sort of detect system that keeps up forward movement. Tested it as a single script in which it worked excellent. If i stand infront of it it waits till it can move forward and if i put a block there it digs it away.
while turtle.forward() ~= true do
if turtle.detect() ~= true
if turtle.dig() ~= true then
print("bedrock in the way")
end
end
if turtle.attack == true then
print("player or monster in the way")
end
end
Now when i implement this as a funtion into the code however like this it seems to completely ignore it. I have the feeling i'm overlooking something. Tried all day to find out way this happens without simply copy pasting codes (since i do want to understand what i'm doing atleast if it works :)/>. Could somebody explain why this is happening ?
local function forward()
while turtle.forward() ~= true do
if turtle.detect() == true then
if turtle.dig() ~= true then
print("bedrock in the way")
end
end
if turtle.attack == true then
print("player or monster in the way")
end
end
end
----- ending local forward
local function refuel()
r = turtle.getFuelLevel()
if r < 60 then
turtle.select(1)
turtle.refuel(2)
end
end
----- ending local refuel
local function melonturtle()
refuel()
for i = 1,14,1 do
forward()
sleep(1)
turtle.turnLeft()
turtle.dig()
for i = 1,2,1 do
turtle.turnRight()
end
turtle.dig()
turtle.turnLeft()
end
for i = 1,2,1 do
turtle.turnRight()
end
for i = 1,14,1 do
forward()
end
for i = 1,2,1 do
turtle.turnLeft()
end
end
----- ending local melonturtle
rednet.open("right")
while true do
term.clear()
term.setCursorPos(1,1)
print("Waiting for commands from advanced pc!")
x,y = rednet.receive()
if x == 278 and y == "go" then
melonturtle()
end
end
Edited on 03 August 2014 - 10:26 PM