mirror of
https://github.com/LDDestroier/CC/
synced 2025-06-27 15:42:59 +00:00
Update cubedig.lua
This commit is contained in:
parent
98fa79a9e9
commit
d4ad8243d0
51
cubedig.lua
51
cubedig.lua
@ -24,13 +24,13 @@ dz = dz - 1
|
|||||||
local dig = function(direction)
|
local dig = function(direction)
|
||||||
if direction == -1 then -- down
|
if direction == -1 then -- down
|
||||||
while turtle.inspectDown() do
|
while turtle.inspectDown() do
|
||||||
turtle.digDown()
|
turtle.digDown()
|
||||||
end
|
end
|
||||||
elseif direction == 1 then -- up
|
elseif direction == 1 then -- up
|
||||||
while turtle.inspectUp() do
|
while turtle.inspectUp() do
|
||||||
turtle.digUp()
|
turtle.digUp()
|
||||||
end
|
end
|
||||||
else -- forwards
|
else -- forwards
|
||||||
while turtle.inspect() do
|
while turtle.inspect() do
|
||||||
turtle.dig()
|
turtle.dig()
|
||||||
end
|
end
|
||||||
@ -48,8 +48,8 @@ local move = function(direction)
|
|||||||
turtle.forward()
|
turtle.forward()
|
||||||
pos.x = pos.x + math.cos(math.rad(pos.f * 90))
|
pos.x = pos.x + math.cos(math.rad(pos.f * 90))
|
||||||
elseif direction == "back" then
|
elseif direction == "back" then
|
||||||
turtle.forward()
|
turtle.forward()
|
||||||
pos.x = pos.x - math.cos(math.rad(pos.f * 90))
|
pos.x = pos.x - math.cos(math.rad(pos.f * 90))
|
||||||
elseif direction == "left" then
|
elseif direction == "left" then
|
||||||
turtle.turnLeft()
|
turtle.turnLeft()
|
||||||
pos.f = (pos.f - 1) % 4
|
pos.f = (pos.f - 1) % 4
|
||||||
@ -94,18 +94,35 @@ 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
|
||||||
for y = 1, math.abs(dy) do
|
if dy > 1 then
|
||||||
for x = 1, dx do
|
move( "up" )
|
||||||
for z = 1, dz do
|
elseif dy < 1 then
|
||||||
dig( 0 )
|
move( "down" )
|
||||||
move( "forward" )
|
end
|
||||||
|
for y = (math.abs(dy) > 1 and 2 or 1), math.abs(dy) do
|
||||||
|
if y % 3 == 1 then
|
||||||
|
for x = 1, dx do
|
||||||
|
for z = 1, dz do
|
||||||
|
UDdig(dy / math.abs(dy), y * (dy / math.abs(dy)), dy)
|
||||||
|
move( "forward" )
|
||||||
|
printData()
|
||||||
|
end
|
||||||
|
turn(doTurn, x < dx)
|
||||||
printData()
|
printData()
|
||||||
end
|
if x < dx then
|
||||||
turn(doTurn, x < dx)
|
doTurn = not doTurn
|
||||||
printData()
|
end
|
||||||
if x < dx then
|
|
||||||
doTurn = not doTurn
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if y ~= math.abs(dy) then
|
if y ~= math.abs(dy) then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user