1
0
mirror of https://github.com/LDDestroier/CC/ synced 2024-06-18 11:19:58 +00:00

Update cubedig.lua

This commit is contained in:
LDDestroier 2019-04-24 22:49:04 -04:00 committed by GitHub
parent e2c38a2bc3
commit 3d4e9915fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,18 +59,28 @@ local move = function(direction)
end
end
local turn = function(dir, doDig)
local UDdig = function(left, check, right)
dig( 0 )
if check > left then
dig( -1 )
end
if check < right then
dig ( 1 )
end
end
local turn = function(dir, doDig, left, check, right)
if dir then
move( "right" )
if doDig then
dig( 0 )
UDig( left, check, right )
move( "forward" )
end
move( "right" )
else
move( "left" )
if doDig then
dig( 0 )
UDig( left, check, right )
move( "forward" )
end
move( "left" )
@ -94,16 +104,6 @@ local printData = function()
print("Fuel: " .. turtle.getFuelLevel())
end
local UDdig = function(left, check, right)
dig( 0 )
if check > left then
dig( -1 )
end
if check < right then
dig ( 1 )
end
end
local doTurn = true
if dy > 1 then
move( "up" )
@ -118,7 +118,7 @@ for y = (math.abs(dy) > 1 and 2 or 1), math.abs(dy) do
move( "forward" )
printData()
end
turn(doTurn, x < dx)
turn(doTurn, x < dx, dy / math.abs(dy), y * (dy / math.abs(dy)), dy)
printData()
if x < dx then
doTurn = not doTurn