1
0
mirror of https://github.com/LDDestroier/CC/ synced 2025-02-22 05:50:02 +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
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 if dir then
move( "right" ) move( "right" )
if doDig then if doDig then
dig( 0 ) UDig( left, check, right )
move( "forward" ) move( "forward" )
end end
move( "right" ) move( "right" )
else else
move( "left" ) move( "left" )
if doDig then if doDig then
dig( 0 ) UDig( left, check, right )
move( "forward" ) move( "forward" )
end end
move( "left" ) move( "left" )
@ -94,16 +104,6 @@ local printData = function()
print("Fuel: " .. turtle.getFuelLevel()) print("Fuel: " .. turtle.getFuelLevel())
end 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 local doTurn = true
if dy > 1 then if dy > 1 then
move( "up" ) move( "up" )
@ -118,7 +118,7 @@ for y = (math.abs(dy) > 1 and 2 or 1), math.abs(dy) do
move( "forward" ) move( "forward" )
printData() printData()
end end
turn(doTurn, x < dx) turn(doTurn, x < dx, dy / math.abs(dy), y * (dy / math.abs(dy)), dy)
printData() printData()
if x < dx then if x < dx then
doTurn = not doTurn doTurn = not doTurn