mirror of
https://github.com/LDDestroier/CC/
synced 2024-12-12 03:00:29 +00:00
Update cubedig.lua
This commit is contained in:
parent
c997faf005
commit
34236d2a41
19
cubedig.lua
19
cubedig.lua
@ -6,6 +6,10 @@ local dx = tonumber(tArg[1])
|
|||||||
local dy = tonumber(tArg[2])
|
local dy = tonumber(tArg[2])
|
||||||
local dz = tonumber(tArg[3])
|
local dz = tonumber(tArg[3])
|
||||||
|
|
||||||
|
if dy == 0 then
|
||||||
|
dy = 1
|
||||||
|
end
|
||||||
|
|
||||||
-- relative position, used for printing a graphic
|
-- relative position, used for printing a graphic
|
||||||
local pos = {
|
local pos = {
|
||||||
x = 0,
|
x = 0,
|
||||||
@ -59,8 +63,10 @@ local move = function(direction)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local UDdig = function(left, check, right)
|
local UDdig = function(left, check, right, doNotDigForwards)
|
||||||
dig( 0 )
|
if not doNotDigForwards then
|
||||||
|
dig( 0 )
|
||||||
|
end
|
||||||
if check > left then
|
if check > left then
|
||||||
dig( -1 )
|
dig( -1 )
|
||||||
end
|
end
|
||||||
@ -106,19 +112,22 @@ end
|
|||||||
|
|
||||||
local doTurn = true
|
local doTurn = true
|
||||||
if dy > 1 then
|
if dy > 1 then
|
||||||
|
dig( 1 )
|
||||||
move( "up" )
|
move( "up" )
|
||||||
elseif dy < 1 then
|
elseif dy < 1 then
|
||||||
|
dig( -1 )
|
||||||
move( "down" )
|
move( "down" )
|
||||||
end
|
end
|
||||||
for y = (math.abs(dy) > 1 and 2 or 1), math.abs(dy) do
|
for y = (math.abs(dy) > 1 and 2 or 1), math.abs(dy) do
|
||||||
if (y % 3 == 2) then
|
if (y % 3 == 2) or (math.abs(dy) - y == 1) then
|
||||||
for x = 1, dx do
|
for x = 1, dx do
|
||||||
for z = 1, dz do
|
for z = 1, dz do
|
||||||
UDdig(dy / math.abs(dy), y * (dy / math.abs(dy)), dy)
|
UDdig(dy / math.abs(dy), y * (dy / math.abs(dy)), dy, false)
|
||||||
move( "forward" )
|
move( "forward" )
|
||||||
|
UDdig(dy / math.abs(dy), y * (dy / math.abs(dy)), dy, true)
|
||||||
printData()
|
printData()
|
||||||
end
|
end
|
||||||
turn(doTurn, x < dx, dy / math.abs(dy), y * (dy / math.abs(dy)), dy)
|
turn(doTurn, x < dx, dy / math.abs(dy), y * (dy / math.abs(dy)), dy, false)
|
||||||
printData()
|
printData()
|
||||||
if x < dx then
|
if x < dx then
|
||||||
doTurn = not doTurn
|
doTurn = not doTurn
|
||||||
|
Loading…
Reference in New Issue
Block a user