summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--technic/tools/chainsaw.lua122
1 files changed, 61 insertions, 61 deletions
diff --git a/technic/tools/chainsaw.lua b/technic/tools/chainsaw.lua
index 0ce96ea..2df700e 100644
--- a/technic/tools/chainsaw.lua
+++ b/technic/tools/chainsaw.lua
@@ -219,53 +219,6 @@ end
-- position above it. This does not return the bottom position to prevent
-- the chainsaw from cutting down nodes below the cutting position.
-- @param pos Sawing position.
--- local function iterSawTries(pos)
--- -- Copy position to prevent mangling it
--- local pos = vector.new(pos)
--- local i = 0
---
--- return function()
--- i = i + 1
--- -- Given a (top view) area like so (where 5 is the starting position):
--- -- X -->
--- -- Z 123
--- -- | 456
--- -- V 789
--- -- This will return positions 1, 4, 7, 2, 8 (skip 5), 3, 6, 9,
--- -- and the position above 5.
--- if i == 1 then
--- -- Move to starting position
--- pos.x = pos.x - 1
--- pos.z = pos.z - 1
--- elseif i == 4 or i == 7 then
--- -- Move to next X and back to start of Z when we reach
--- -- the end of a Z line.
--- pos.x = pos.x + 1
--- pos.z = pos.z - 2
--- elseif i == 5 then
--- -- Skip the middle position (we've already run on it)
--- -- and double-increment the counter.
--- pos.z = pos.z + 2
--- i = i + 1
--- elseif i <= 9 then
--- -- Go to next Z.
--- pos.z = pos.z + 1
--- elseif i == 10 then
--- -- Move back to center and up.
--- -- The Y+ position must be last so that we don't dig
--- -- straight upward and not come down (since the Y-
--- -- position isn't checked).
--- pos.x = pos.x - 1
--- pos.z = pos.z - 1
--- pos.y = pos.y + 1
--- else
--- return nil
--- end
--- return pos
--- end
--- end
-
-
local function iterSawTries(pos)
-- Copy position to prevent mangling it
local pos = vector.new(pos)
@@ -275,37 +228,35 @@ local function iterSawTries(pos)
i = i + 1
-- Given a (top view) area like so (where 5 is the starting position):
-- X -->
- -- Z 1 2 3 4 5
- -- | 6 7 8 9 10
- -- | 11 12 13 14 15
- -- | 16 17 18 19 20
- -- V 21 22 23 24 25
+ -- Z 123
+ -- | 456
+ -- V 789
-- This will return positions 1, 4, 7, 2, 8 (skip 5), 3, 6, 9,
-- and the position above 5.
if i == 1 then
-- Move to starting position
- pos.x = pos.x - 2
- pos.z = pos.z - 2
- elseif i == 6 or i == 11 or i == 16 or i == 21 then
+ pos.x = pos.x - 1
+ pos.z = pos.z - 1
+ elseif i == 4 or i == 7 then
-- Move to next X and back to start of Z when we reach
-- the end of a Z line.
pos.x = pos.x + 1
- pos.z = pos.z - 4
- elseif i == 13 then
+ pos.z = pos.z - 2
+ elseif i == 5 then
-- Skip the middle position (we've already run on it)
-- and double-increment the counter.
pos.z = pos.z + 2
i = i + 1
- elseif i <= 25 then
+ elseif i <= 9 then
-- Go to next Z.
pos.z = pos.z + 1
- elseif i == 26 then
+ elseif i == 10 then
-- Move back to center and up.
-- The Y+ position must be last so that we don't dig
-- straight upward and not come down (since the Y-
-- position isn't checked).
- pos.x = pos.x - 2
- pos.z = pos.z - 2
+ pos.x = pos.x - 1
+ pos.z = pos.z - 1
pos.y = pos.y + 1
else
return nil
@@ -314,6 +265,55 @@ local function iterSawTries(pos)
end
end
+
+-- local function iterSawTries(pos)
+-- -- Copy position to prevent mangling it
+-- local pos = vector.new(pos)
+-- local i = 0
+--
+-- return function()
+-- i = i + 1
+-- -- Given a (top view) area like so (where 5 is the starting position):
+-- -- X -->
+-- -- Z 1 2 3 4 5
+-- -- | 6 7 8 9 10
+-- -- | 11 12 13 14 15
+-- -- | 16 17 18 19 20
+-- -- V 21 22 23 24 25
+-- -- This will return positions 1...21, 2..,22, 3...23 (skip 13), 4...24, 5...25
+-- -- and the position above 13.
+-- if i == 1 then
+-- -- Move to starting position
+-- pos.x = pos.x - 2
+-- pos.z = pos.z - 2
+-- elseif i == 6 or i == 11 or i == 16 or i == 21 then
+-- -- Move to next X and back to start of Z when we reach
+-- -- the end of a Z line.
+-- pos.x = pos.x + 1
+-- pos.z = pos.z - 4
+-- elseif i == 13 then
+-- -- Skip the middle position (we've already run on it)
+-- -- and double-increment the counter.
+-- pos.z = pos.z + 2
+-- i = i + 1
+-- elseif i <= 25 then
+-- -- Go to next Z.
+-- pos.z = pos.z + 1
+-- elseif i == 26 then
+-- -- Move back to center and up.
+-- -- The Y+ position must be last so that we don't dig
+-- -- straight upward and not come down (since the Y-
+-- -- position isn't checked).
+-- pos.x = pos.x - 2
+-- pos.z = pos.z - 2
+-- pos.y = pos.y + 1
+-- else
+-- return nil
+-- end
+-- return pos
+-- end
+-- end
+
-- This function does all the hard work. Recursively we dig the node at hand
-- if it is in the table and then search the surroundings for more stuff to dig.
local function recursive_dig(pos, remaining_charge)