This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Runewar's profile picture

Making a turtle mine with rednet

Started by Runewar, 13 April 2012 - 10:52 PM
Runewar #1
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
Luanub #2
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
Runewar #3
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"
Luanub #4
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
Runewar #5
Posted 14 April 2012 - 01:26 AM
Now it can dig down, but wont return to the surface
Luanub #6
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
Runewar #7
Posted 14 April 2012 - 01:37 AM
Works perfectly, thanks for all the help :P/>/>
mesika #8
Posted 16 April 2012 - 01:29 AM
Is there a way to make turtles mine for a specific type of block or resource?