9 posts
Posted 14 April 2012 - 12:52 AM
This is the code i have setup for my Turtle i want to mine, and then return to the surface, i know its bad but im just starting ;P
Turtle-
rednet.open("right")
rednet.receive()
if text = "dig" then
turtle.digDown 30
(How do i make it go back up also?)
Computer-
rednet.open("right")
rednet.broadcast("dig")
I use the turtle program before computer program
1111 posts
Location
Portland OR
Posted 14 April 2012 - 12:57 AM
Your going to run into a couple of issues, I've made some corrections and added coding to return to the surface.
rednet.open("right")
local id, text = rednet.receive() -- need to capture the output from the receive in some vars
if text = "dig" then
for x=1, 30 do --repeats code 30 times
turtle.digDown() -- can only go 1 block at a time thus the for loop
turtle.down() -- move down after digging
end
for x=1, 30 do
turtle.up()
end
end
9 posts
Posted 14 April 2012 - 01:18 AM
rednet.open("right")
local id, text = rednet.receive()
if text = "dig" then
for x=1, 30 do
turtle.digDown()
turtle.down()
end
for x=1, 30 do
turtle.up()
end
end
With that coding I get the error "bios:206: [string "p"]:3: 'then' expected
there are also 2 spaces before each line with "turtle"
1111 posts
Location
Portland OR
Posted 14 April 2012 - 01:22 AM
Sorry I didnt notice = syntax is a = 1 or if a == 1
= to assign the value
== to check a value
so change
if text = "dig" then
to
if text == "dig" then
9 posts
Posted 14 April 2012 - 01:26 AM
Now it can dig down, but wont return to the surface
1111 posts
Location
Portland OR
Posted 14 April 2012 - 01:33 AM
Hmm it should work, only thing I can think of is trying to move one of the ends up. Might be causing a logic issue.
I'm not to where I can test this unfortunately.
rednet.open("right")
local id, text = rednet.receive() -- need to capture the output from the receive in some vars
if text = "dig" then
for x=1, 30 do --repeats code 30 times
turtle.digDown() -- can only go 1 block at a time thus the for loop
turtle.down() -- move down after digging
end
end
for x=1, 30 do
turtle.up()
end
9 posts
Posted 14 April 2012 - 01:37 AM
Works perfectly, thanks for all the help :P/>/>
1 posts
Posted 16 April 2012 - 01:29 AM
Is there a way to make turtles mine for a specific type of block or resource?