1
0
mirror of https://github.com/LDDestroier/CC/ synced 2024-12-13 03:30:28 +00:00

Update cubedig.lua

This commit is contained in:
LDDestroier 2019-04-24 23:13:07 -04:00 committed by GitHub
parent c997faf005
commit 34236d2a41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
if not doNotDigForwards then
dig( 0 ) 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