12 posts
Posted 10 April 2012 - 01:37 PM
Hi,
I'm struggling to understand how to code for the turtle, I thought i would try to code a simple script to mine out a 3x3 branch but i even got stuck with this.
Is there any tutorials about I've looked around and haven't found anything that's applicable. I really just need to follow something/one on how to do the simple stuff like moving for x number of blocks..etc
I did get the turtle to mine in a straight line but it ran off and i had to mine/chase it down…lol…
Thanks
259 posts
Location
Australia
Posted 10 April 2012 - 02:34 PM
in your script try some of these code/lua whatever u want to call the
———————
turtle.forward()
turtle.back()
turtle.dig()
turtle.up()
turtle.down()
turtle.left()
turtle.right()
————————
try some on those.
im not sure if all of them code/lua etc are correct (i dont work with turtles much) but those are just some i tryed to remember of the top of my head.
please correct me if some are wrong
————————-
hope i helped
12 posts
Posted 10 April 2012 - 03:25 PM
Yeah I am trying to use those commands, I did dig down some and then set the turtle in front of a wall of blocks
i tried a few things and got varied results:
turtle.dig()
turtle.forward()
dug 1 block moved forward then stopped.
so i tried:
while turtle.detect() do
turtle.dig()
end
The turtle raced off mining 1 block row and i had to chase it down, I think i have to do something like this to get a 3x3x? length tunnel
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digUp()
turtle.turnRight()
turtle.dig()
turtle.digDown()
turtle.digDown()
etc…
but that seems rather long winded. So i guessing you would need functions maybe..or a variable. I've look at other peoples code but cant figure out how it works.
259 posts
Location
Australia
Posted 10 April 2012 - 04:26 PM
Yeah I am trying to use those commands, I did dig down some and then set the turtle in front of a wall of blocks
i tried a few things and got varied results:
turtle.dig()
turtle.forward()
dug 1 block moved forward then stopped.
so i tried:
while turtle.detect() do
turtle.dig()
end
The turtle raced off mining 1 block row and i had to chase it down, I think i have to do something like this to get a 3x3x? length tunnel
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digUp()
turtle.turnRight()
turtle.dig()
turtle.digDown()
turtle.digDown()
etc…
but that seems rather long winded. So i guessing you would need functions maybe..or a variable. I've look at other peoples code but cant figure out how it works.
ok i just made a tunnel program just go 3 blocks down and place the turtle and run the program and it will do its job but use terminate to stop it :P/>/>
while true do
-- MADE BY DJBLOCKSAWAY
shell.run "clear"
print "Place Me At The Bottom Left Corner"
print "Of A Block Where You Want The Tunnel"
print "To Start. Use CTRL+T To Stop Me!"
turtle.dig()
turtle.up()
turtle.dig()
turtle.up()
turtle.dig()
turtle.turnRight()
turtle.dig()
turtle.down()
turtle.dig()
turtle.down()
turtle.dig()
turtle.up()
turtle.up()
turtle.forward()
turtle.turnLeft()
turtle.dig()
turtle.down()
turtle.dig()
turtle.down()
turtle.dig()
turtle.turnRight()
turtle.dig()
turtle.up()
turtle.dig()
turtle.up()
turtle.dig()
turtle.down()
turtle.down()
turtle.forward()
turtle.turnLeft()
turtle.dig()
turtle.up()
turtle.dig()
turtle.up()
turtle.dig()
turtle.down()
turtle.down()
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.forward()
turtle.turnRight()
turtle.dig()
turtle.forward()
end
474 posts
Posted 10 April 2012 - 05:50 PM
To make it go a certain amount of times, it's pretty easy. Just change the 2 on "local amount = " to how much you want it to dig then move forward. Of course you can change what it does in the for loop.
local amount = 2
local blocks = 0
for doNotChangeThis=1,amount do
turtle.dig()
blocks = blocks+1
turtle.forward()
if blocks > 1 then
print("Mined "..blocks.." blocks!")
end
if blocks == 1 then
print("Mined "..blocks.." block!")
end
end
12 posts
Posted 10 April 2012 - 10:11 PM
To make it go a certain amount of times, it's pretty easy. Just change the 2 on "local amount = " to how much you want it to dig then move forward. Of course you can change what it does in the for loop.
local amount = 2
local blocks = 0
for doNotChangeThis=1,amount do
turtle.dig()
blocks = blocks+1
turtle.forward()
if blocks > 1 then
print("Mined "..blocks.." blocks!")
end
if blocks == 1 then
print("Mined "..blocks.." block!")
end
end
Thanks for the code i tried it out and it works really well now to make it do more would i use this code then turn the turtle and then repeat your code? etc etc?
436 posts
Posted 10 April 2012 - 10:56 PM
Hmm, how about something like this:
local amount = --whatever, you can even have it as an arg by putting "..." here
local blocks = 0
fiunction digRow(howFar)
for doNotChangeThis=1, howFar do
turtle.dig()
blocks = blocks+1
turtle.forward()
if blocks > 1 then
print("Mined "..blocks.." blocks!")
end
if blocks == 1 then
print("Mined "..blocks.." block!")
end
end
end
for leaveIt = 1, 3 do -- latter number can be changed to whatever you want your width to be.
digRow(amount)
turtle.turnRight() --Or Left, if you shoot with your right hand
turtle.dig()
turtle.forward()
turtle.turnRight()
if leaveIt == 1 then
amount = amount - 1
end
end
That makes one layer, 3 wide and however long you want the tunnel. I'll leave it to you to figure out how to make more layers.
454 posts
Location
London
Posted 11 April 2012 - 12:05 AM
This topic is in the wrong forum. I'm very disappointed that you replied to it.