mirror of
https://github.com/LDDestroier/CC/
synced 2025-02-22 05:50:02 +00:00
Update cubedig.lua
This commit is contained in:
parent
e2c38a2bc3
commit
3d4e9915fd
28
cubedig.lua
28
cubedig.lua
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user