31 posts
Posted 26 November 2012 - 07:57 AM
I'm trying to make a mining turtle clear a Eleven by Eleven area but I can't figure out how to redo sections of code a number of time.
http://pastebin.com/np68sbbbThere's the pastebin of my code, what am I doing wrong here? Could someone please help me out here?
1688 posts
Location
'MURICA
Posted 26 November 2012 - 08:10 AM
You really aren't doing anything wrong (minus the "end" on the last line that shouldn't be there), except digging in a spiral pattern is much more difficult than if you were digging in a zig-zag pattern.
local function digIfDetect()
if turtle.detect() then turtle.dig() end
end
for i=1, 11 do
for ii=1, 11 do
digIfDetect()
turtle.forward()
end
if i%2 == 0 then
turtle.turnLeft()
digIfDetect()
turtle.forward()
turtle.turnLeft()
else
turtle.turnRight()
digIfDetect()
turtle.forward()
turtle.turnRight()
end
end
The "digIfDetect()" part is only so that it doesn't try to dig empty blocks.
31 posts
Posted 26 November 2012 - 08:18 AM
Thank you very much!
I'll edit it as per your suggestions and update this post with the details
31 posts
Posted 26 November 2012 - 08:58 AM
Nevermind! i got it! thank you!