From 31a4d89a4960a1367428d74f89e4eccd72cc1ba1 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Wed, 28 Jul 2021 17:39:09 +0100 Subject: [PATCH 01/55] TEST: implement split_shell --- .../utils/strings/split_shell.lua | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 worldeditadditions/utils/strings/split_shell.lua diff --git a/worldeditadditions/utils/strings/split_shell.lua b/worldeditadditions/utils/strings/split_shell.lua new file mode 100644 index 0000000..6b8b2ba --- /dev/null +++ b/worldeditadditions/utils/strings/split_shell.lua @@ -0,0 +1,72 @@ +function is_whitespace(char) + return char == " " or char == "\t" or char == "\r" or char == "\n" +end + +function split_shell(text) + local text_length = #text + local scan_pos = 1 + local result = { } + local acc = {} + local mode = "NORMAL" -- NORMAL, INSIDE_QUOTES_SINGLE, INSIDE_QUOTES_DOUBLE + + + for i=1,text_length do + local prevchar = "" + local curchar = text:sub(i,i) + local nextchar = "" + local nextnextchar = "" + if i > 1 then prevchar = text:sub(i-1, i-1) end + if i < text_length then nextchar = text:sub(i+1, i+1) end + if i+1 < text_length then nextnextchar = text:sub(i+2, i+2) end + + if mode == "NORMAL" then + if is_whitespace(curchar) and #acc > 0 then + table.insert(result, table.concat(acc, "")) + acc = {} + elseif (curchar == "\"" or curchar == "'") and #acc == 0 and prevchar ~= "\\" then + if curchar == "\"" then + mode = "INSIDE_QUOTES_DOUBLE" + else + mode = "INSIDE_QUOTES_SINGLE" + end + else + table.insert(acc, curchar) + end + elseif mode == "INSIDE_QUOTES_DOUBLE" then + if curchar == "\"" and prevchar ~= "\\" and is_whitespace(nextchar) then + -- It's the end of a quote! + mode = "NORMAL" + elseif (curchar == "\\" and nextchar ~= "\"" and not is_whitespace(nextnextchar)) or curchar ~= "\\" then + -- It's a regular character + table.insert(acc, curchar) + end + elseif mode == "INSIDE_QUOTES_SINGLE" then + if curchar == "'" and prevchar ~= "\\" and is_whitespace(nextchar) then + -- It's the end of a quote! + mode = "NORMAL" + elseif (curchar == "\\" and nextchar ~= "'" and not is_whitespace(nextnextchar)) or curchar ~= "\\" then + -- It's a regular character + table.insert(acc, curchar) + end + end + end + + if #acc > 0 then + table.insert(result, table.concat(acc, "")) + end + return result +end + +function test(text) + print("Source", text) + for i,value in ipairs(split_shell(text)) do + print("i", i, "→", value) + end + print("************") +end + +test("yay yay yay") +test("yay \"yay yay\" yay") +test("yay \"yay\\\" yay\" yay") +test("yay \"yay 'inside quotes' yay\" yay") +test("yay 'inside quotes' another") From c282e286bbf1d61ae9ffef7cbd14ca0019e68c5f Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Wed, 28 Jul 2021 17:49:18 +0100 Subject: [PATCH 02/55] split_shell: correctly handle escaping edge cases --- worldeditadditions/utils/strings/split_shell.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/worldeditadditions/utils/strings/split_shell.lua b/worldeditadditions/utils/strings/split_shell.lua index 6b8b2ba..46f1e0b 100644 --- a/worldeditadditions/utils/strings/split_shell.lua +++ b/worldeditadditions/utils/strings/split_shell.lua @@ -36,7 +36,10 @@ function split_shell(text) if curchar == "\"" and prevchar ~= "\\" and is_whitespace(nextchar) then -- It's the end of a quote! mode = "NORMAL" - elseif (curchar == "\\" and nextchar ~= "\"" and not is_whitespace(nextnextchar)) or curchar ~= "\\" then + elseif (curchar == "\\" and ( + nextchar ~= "\"" + or (nextchar == "\"" and not is_whitespace(nextnextchar)) + )) or curchar ~= "\\" then -- It's a regular character table.insert(acc, curchar) end @@ -44,7 +47,10 @@ function split_shell(text) if curchar == "'" and prevchar ~= "\\" and is_whitespace(nextchar) then -- It's the end of a quote! mode = "NORMAL" - elseif (curchar == "\\" and nextchar ~= "'" and not is_whitespace(nextnextchar)) or curchar ~= "\\" then + elseif (curchar == "\\" and ( + nextchar ~= "'" + or (nextchar == "'" and not is_whitespace(nextnextchar)) + )) or curchar ~= "\\" then -- It's a regular character table.insert(acc, curchar) end @@ -70,3 +76,8 @@ test("yay \"yay yay\" yay") test("yay \"yay\\\" yay\" yay") test("yay \"yay 'inside quotes' yay\" yay") test("yay 'inside quotes' another") +test("y\"ay \"yay 'in\\\"side quotes' yay\" y\\\"ay") + +-- for i=1,10000 do +-- split_shell("y\"ay \"yay 'in\\\"side quotes' yay\" y\\\"ay") +-- end From 6a77b3cd215bb32ae1ef3a1fc5b1b40c440d51ec Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Wed, 28 Jul 2021 17:54:44 +0100 Subject: [PATCH 03/55] split_shell: fix escape handling by unwinding escaping by 1 level --- .../utils/strings/split_shell.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/worldeditadditions/utils/strings/split_shell.lua b/worldeditadditions/utils/strings/split_shell.lua index 46f1e0b..d33fc41 100644 --- a/worldeditadditions/utils/strings/split_shell.lua +++ b/worldeditadditions/utils/strings/split_shell.lua @@ -2,6 +2,15 @@ function is_whitespace(char) return char == " " or char == "\t" or char == "\r" or char == "\n" end +local function table_map(tbl, func) + local result = {} + for i,value in ipairs(tbl) do + local newval = func(value, i) + if newval ~= nil then table.insert(result, newval) end + end + return result +end + function split_shell(text) local text_length = #text local scan_pos = 1 @@ -60,7 +69,11 @@ function split_shell(text) if #acc > 0 then table.insert(result, table.concat(acc, "")) end - return result + + -- Unwind all escapes by 1 level + return table_map(result, function(str) + return str:gsub("\\([\"'\\])", "%1") + end) end function test(text) @@ -74,7 +87,7 @@ end test("yay yay yay") test("yay \"yay yay\" yay") test("yay \"yay\\\" yay\" yay") -test("yay \"yay 'inside quotes' yay\" yay") +test("yay \"yay 'inside quotes' yay\\\"\" yay") test("yay 'inside quotes' another") test("y\"ay \"yay 'in\\\"side quotes' yay\" y\\\"ay") From b708fec2dbb99c310727948f55cfc2c9e15a4a2d Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Wed, 28 Jul 2021 18:07:21 +0100 Subject: [PATCH 04/55] fixup --- worldeditadditions/utils/strings/split_shell.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/worldeditadditions/utils/strings/split_shell.lua b/worldeditadditions/utils/strings/split_shell.lua index d33fc41..e7b48c5 100644 --- a/worldeditadditions/utils/strings/split_shell.lua +++ b/worldeditadditions/utils/strings/split_shell.lua @@ -90,7 +90,3 @@ test("yay \"yay\\\" yay\" yay") test("yay \"yay 'inside quotes' yay\\\"\" yay") test("yay 'inside quotes' another") test("y\"ay \"yay 'in\\\"side quotes' yay\" y\\\"ay") - --- for i=1,10000 do --- split_shell("y\"ay \"yay 'in\\\"side quotes' yay\" y\\\"ay") --- end From bd1da727a473a3845ca2b464b8c67dbfd989b2e1 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Wed, 28 Jul 2021 18:32:41 +0100 Subject: [PATCH 05/55] Integrate split_shell into worldeditadditions ...it's not used anywhere yet though --- worldeditadditions/utils/strings/init.lua | 9 ++-- .../utils/strings/split_shell.lua | 45 +++++++++---------- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/worldeditadditions/utils/strings/init.lua b/worldeditadditions/utils/strings/init.lua index 167ac70..32a8454 100644 --- a/worldeditadditions/utils/strings/init.lua +++ b/worldeditadditions/utils/strings/init.lua @@ -1,3 +1,6 @@ -dofile(worldeditadditions.modpath.."/utils/strings/split.lua") -dofile(worldeditadditions.modpath.."/utils/strings/polyfill.lua") -dofile(worldeditadditions.modpath.."/utils/strings/tochars.lua") +local wea = worldeditadditions + +dofile(wea.modpath.."/utils/strings/split.lua") +dofile(wea.modpath.."/utils/strings/polyfill.lua") +dofile(wea.modpath.."/utils/strings/tochars.lua") +wea.split_shell = dofile(wea.modpath.."/utils/strings/split_shell.lua") diff --git a/worldeditadditions/utils/strings/split_shell.lua b/worldeditadditions/utils/strings/split_shell.lua index e7b48c5..32d4d0d 100644 --- a/worldeditadditions/utils/strings/split_shell.lua +++ b/worldeditadditions/utils/strings/split_shell.lua @@ -1,17 +1,10 @@ -function is_whitespace(char) - return char == " " or char == "\t" or char == "\r" or char == "\n" +local table_map = dofile(worldeditadditions.modpath.."/utils/tables/table_map.lua") + +local function is_whitespace(char) + return char:match("%s") end -local function table_map(tbl, func) - local result = {} - for i,value in ipairs(tbl) do - local newval = func(value, i) - if newval ~= nil then table.insert(result, newval) end - end - return result -end - -function split_shell(text) +local function split_shell(text) local text_length = #text local scan_pos = 1 local result = { } @@ -76,17 +69,19 @@ function split_shell(text) end) end -function test(text) - print("Source", text) - for i,value in ipairs(split_shell(text)) do - print("i", i, "→", value) - end - print("************") -end +return split_shell -test("yay yay yay") -test("yay \"yay yay\" yay") -test("yay \"yay\\\" yay\" yay") -test("yay \"yay 'inside quotes' yay\\\"\" yay") -test("yay 'inside quotes' another") -test("y\"ay \"yay 'in\\\"side quotes' yay\" y\\\"ay") +-- function test(text) +-- print("Source", text) +-- for i,value in ipairs(split_shell(text)) do +-- print("i", i, "→", value) +-- end +-- print("************") +-- end +-- +-- test("yay yay yay") +-- test("yay \"yay yay\" yay") +-- test("yay \"yay\\\" yay\" yay") +-- test("yay \"yay 'inside quotes' yay\\\"\" yay") +-- test("yay 'inside quotes' another") +-- test("y\"ay \"yay 'in\\\"side quotes' yay\" y\\\"ay") From ecb846fcfe66420036e30c861aeeba5c4cceaee6 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:03:39 +0100 Subject: [PATCH 06/55] //erode river: fix undefined global variable --- worldeditadditions/lib/erode/river.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions/lib/erode/river.lua b/worldeditadditions/lib/erode/river.lua index c3d033c..df200a4 100644 --- a/worldeditadditions/lib/erode/river.lua +++ b/worldeditadditions/lib/erode/river.lua @@ -47,7 +47,7 @@ function worldeditadditions.erode.river(heightmap_initial, heightmap, heightmap_ local height_up = heightmap[hi] local height_down = heightmap[hi] local height_left = heightmap[hi] - local height_down = heightmap[hi] + local height_right = heightmap[hi] if x > 0 then height_left = heightmap[z*heightmap_size.x + x-1] end if x < heightmap_size.x - 1 then height_right = heightmap[z*heightmap_size.x + x+1] end From 92451cf125abc241ddf7c7602639d785492c31b7 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:05:45 +0100 Subject: [PATCH 07/55] scale.lua: fix inconsistent whitespace --- worldeditadditions_commands/commands/scale.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions_commands/commands/scale.lua b/worldeditadditions_commands/commands/scale.lua index 01a3503..efebcaf 100644 --- a/worldeditadditions_commands/commands/scale.lua +++ b/worldeditadditions_commands/commands/scale.lua @@ -37,7 +37,7 @@ worldedit.register_command("scale", { if #parts == 2 then if not (parts[1] == "x" or parts[1] == "y" or parts[1] == "z" - or parts[1] == "-x" or parts[1] == "-y" or parts[1] == "-z") then + or parts[1] == "-x" or parts[1] == "-y" or parts[1] == "-z") then return false, "Error: Got 2 arguments, but the first doesn't look like the name of an axis." end local axis = parts[1] From f7cda8c817cd35da3bf43664096af4acd09e55e7 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:06:44 +0100 Subject: [PATCH 08/55] //subdivide: Fix referencing undefined global variable --- worldeditadditions_commands/commands/meta/subdivide.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions_commands/commands/meta/subdivide.lua b/worldeditadditions_commands/commands/meta/subdivide.lua index 636fd9b..5acf272 100644 --- a/worldeditadditions_commands/commands/meta/subdivide.lua +++ b/worldeditadditions_commands/commands/meta/subdivide.lua @@ -93,7 +93,7 @@ worldedit.register_command("subdivide", { local cmd_args_parsed = {cmd.parse(args)} local success = table.remove(cmd_args_parsed, 1) if not success then - return false, cmd_name..": "..(parsed[1] or "invalid usage") + return false, cmd_name..": "..(cmd_args_parsed[1] or "invalid usage") end wea.subdivide(pos1, pos2, chunk_size, function(cpos1, cpos2, stats) From 7ef3d694a75f9935ee9fc362529eb5913c1eb487 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:12:28 +0100 Subject: [PATCH 09/55] Add syntax check --- tests.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests.sh b/tests.sh index d355f72..002c8ee 100755 --- a/tests.sh +++ b/tests.sh @@ -2,6 +2,12 @@ # Make sure the current directory is the location of this script to simplify matters cd "$(dirname "$(readlink -f "$0")")" || { echo "Error: Failed to cd to script directory" >&2; exit 1; }; +# To run Luacheck: +# +# luacheck . --ignore 631 61[124] 412 21[123] --globals minetest worldedit worldeditadditions worldeditadditions_commands worldeditadditions_core vector assert bit it describe bonemeal --codes -j "$(nproc)" --quiet --exclude-files .luarocks/* +# +# This is a work-in-progress, as it currently throws an *enormous* number of warnings. + ############################################################################### log_msg() { @@ -35,6 +41,10 @@ run_setup() { luarocks --tree "${luarocks_root}" install busted; } +run_syntax_check() { + find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; +} + run_test() { .luarocks/bin/busted --no-auto-insulate --pattern ".test.lua" .tests; } @@ -48,6 +58,7 @@ case "${mode}" in if [[ ! -d "${luarocks_root}" ]]; then run_setup; fi + run_syntax_check; run_test; ;; From b2fcc4d72f887335c8477dad8e828ad605cfef39 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:16:43 +0100 Subject: [PATCH 10/55] GitHub actions --- github-actions-demo.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 github-actions-demo.yml diff --git a/github-actions-demo.yml b/github-actions-demo.yml new file mode 100644 index 0000000..4f7e717 --- /dev/null +++ b/github-actions-demo.yml @@ -0,0 +1,19 @@ +name: "WorldEditAdditions Continuous Integration" +on: [push] +jobs: + Syntax-Check: + runs-on: minideb + name: Install Dependencies + run: install_packages lua5.1 + run: uname -a + run: lua --version + name: Perform Check + run: + Busted: + runs-on: minideb + - name: Install Dependencies + run: install_packages lua5.1 luarocks lua-check + run: uname -a + run: lua --version + - name: Run Tests + run: ./tests.sh From 21043f7c9d3d67ce360c16f1e2dad6bccaeaeca1 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:19:46 +0100 Subject: [PATCH 11/55] Move GitHub Actions definition --- github-actions-demo.yml => .github/workflows/main.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename github-actions-demo.yml => .github/workflows/main.yml (100%) diff --git a/github-actions-demo.yml b/.github/workflows/main.yml similarity index 100% rename from github-actions-demo.yml rename to .github/workflows/main.yml From baf8a5e02d7cb92b90ad53a54b4cca74a200d13f Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:22:51 +0100 Subject: [PATCH 12/55] GitHub Actions: fix --- .github/workflows/main.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4f7e717..194dd03 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,19 +1,19 @@ name: "WorldEditAdditions Continuous Integration" on: [push] jobs: - Syntax-Check: - runs-on: minideb - name: Install Dependencies - run: install_packages lua5.1 - run: uname -a - run: lua --version - name: Perform Check - run: - Busted: - runs-on: minideb - - name: Install Dependencies - run: install_packages lua5.1 luarocks lua-check - run: uname -a - run: lua --version - - name: Run Tests - run: ./tests.sh + Syntax-Check: + runs-on: minideb + name: Install Dependencies + run: install_packages lua5.1 + run: uname -a + run: lua --version + name: Perform Check + run: find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; + Busted: + runs-on: minideb + - name: Install Dependencies + run: install_packages lua5.1 luarocks lua-check + run: uname -a + run: lua --version + - name: Run Tests + run: ./tests.sh From 971deaa63ba4297c92c9a90dc553929ec817ec53 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:27:04 +0100 Subject: [PATCH 13/55] GitHub Actions: does this work? I hate yaml SO MUCH. --- .github/workflows/main.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 194dd03..a69b21f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,15 +2,15 @@ name: "WorldEditAdditions Continuous Integration" on: [push] jobs: Syntax-Check: - runs-on: minideb - name: Install Dependencies - run: install_packages lua5.1 - run: uname -a - run: lua --version - name: Perform Check - run: find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; + - runs-on: minideb + - name: Install Dependencies + run: install_packages lua5.1 + run: uname -a + run: lua --version + - name: Perform Check + run: find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; Busted: - runs-on: minideb + - runs-on: minideb - name: Install Dependencies run: install_packages lua5.1 luarocks lua-check run: uname -a From 7a77fffbca7801cd33dd01327180309432616fbf Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:27:38 +0100 Subject: [PATCH 14/55] GitHub Actions: and again --- .github/workflows/main.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a69b21f..1378d0d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,18 +2,18 @@ name: "WorldEditAdditions Continuous Integration" on: [push] jobs: Syntax-Check: - - runs-on: minideb - - name: Install Dependencies - run: install_packages lua5.1 - run: uname -a - run: lua --version - - name: Perform Check - run: find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; + runs-on: minideb + name: Install Dependencies + run: install_packages lua5.1 + run: uname -a + run: lua --version + name: Perform Check + run: find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; Busted: - - runs-on: minideb - - name: Install Dependencies - run: install_packages lua5.1 luarocks lua-check - run: uname -a - run: lua --version - - name: Run Tests - run: ./tests.sh + runs-on: minideb + name: Install Dependencies + run: install_packages lua5.1 luarocks lua-check + run: uname -a + run: lua --version + name: Run Tests + run: ./tests.sh From ce923353f2997673db6f43dc068309c9189d6a33 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:28:13 +0100 Subject: [PATCH 15/55] GitHub Actions: define steps --- .github/workflows/main.yml | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1378d0d..4c79efe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,17 +3,19 @@ on: [push] jobs: Syntax-Check: runs-on: minideb - name: Install Dependencies - run: install_packages lua5.1 - run: uname -a - run: lua --version - name: Perform Check - run: find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; + steps: + name: Install Dependencies + run: install_packages lua5.1 + run: uname -a + run: lua --version + name: Perform Check + run: find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; Busted: runs-on: minideb - name: Install Dependencies - run: install_packages lua5.1 luarocks lua-check - run: uname -a - run: lua --version - name: Run Tests - run: ./tests.sh + steps: + name: Install Dependencies + run: install_packages lua5.1 luarocks lua-check + run: uname -a + run: lua --version + name: Run Tests + run: ./tests.sh From 5a211279e2144c8a5c29461d8140e29d96f076ed Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:28:48 +0100 Subject: [PATCH 16/55] =?UTF-8?q?GitHub=20Actions:=20main=20=E2=86=92=20te?= =?UTF-8?q?st?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/{main.yml => test.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{main.yml => test.yml} (91%) diff --git a/.github/workflows/main.yml b/.github/workflows/test.yml similarity index 91% rename from .github/workflows/main.yml rename to .github/workflows/test.yml index 4c79efe..35f238e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: "WorldEditAdditions Continuous Integration" +name: "CI Tests" on: [push] jobs: Syntax-Check: From c86cff6de691252306856c399b1a0a6ea3f9c508 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:32:20 +0100 Subject: [PATCH 17/55] GitHub Actions: alter steps values --- .github/workflows/test.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 35f238e..e564493 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,18 +4,18 @@ jobs: Syntax-Check: runs-on: minideb steps: - name: Install Dependencies - run: install_packages lua5.1 - run: uname -a - run: lua --version - name: Perform Check - run: find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; + - name: Install Dependencies + run: install_packages lua5.1 + run: uname -a + run: lua --version + - name: Perform Check + run: find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; Busted: runs-on: minideb steps: - name: Install Dependencies - run: install_packages lua5.1 luarocks lua-check - run: uname -a - run: lua --version - name: Run Tests - run: ./tests.sh + - name: Install Dependencies + run: install_packages lua5.1 luarocks lua-check + run: uname -a + run: lua --version + - name: Run Tests + run: ./tests.sh From caee6a8443747fdbcc95f3b2519d81bee6484525 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:34:53 +0100 Subject: [PATCH 18/55] fixup --- .github/workflows/test.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e564493..8cd124f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,16 +6,26 @@ jobs: steps: - name: Install Dependencies run: install_packages lua5.1 + + - name: uname -a run: uname -a + + - name: lua --version run: lua --version + - name: Perform Check run: find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; Busted: runs-on: minideb steps: - name: Install Dependencies - run: install_packages lua5.1 luarocks lua-check + run: install_packages lua5.1 luarocks + + - name: uname -a run: uname -a + + - name: lua --version run: lua --version + - name: Run Tests run: ./tests.sh From 1c4310b6dd985ff200be08c1341b7210d24e623d Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:35:46 +0100 Subject: [PATCH 19/55] GitHub Actions: Fix docker container name --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8cd124f..1c869c4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,7 +2,7 @@ name: "CI Tests" on: [push] jobs: Syntax-Check: - runs-on: minideb + runs-on: bitnami/minideb steps: - name: Install Dependencies run: install_packages lua5.1 @@ -16,7 +16,7 @@ jobs: - name: Perform Check run: find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; Busted: - runs-on: minideb + runs-on: bitnami/minideb steps: - name: Install Dependencies run: install_packages lua5.1 luarocks From 591ffb977e664cc3f6353c27412c2c29bf810188 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:37:48 +0100 Subject: [PATCH 20/55] fixup --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1c869c4..440d924 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,10 +2,10 @@ name: "CI Tests" on: [push] jobs: Syntax-Check: - runs-on: bitnami/minideb + runs-on: ubuntu-latest steps: - name: Install Dependencies - run: install_packages lua5.1 + run: apt install lua5.1 - name: uname -a run: uname -a @@ -16,10 +16,10 @@ jobs: - name: Perform Check run: find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; Busted: - runs-on: bitnami/minideb + runs-on: ubuntu-latest steps: - name: Install Dependencies - run: install_packages lua5.1 luarocks + run: apt install lua5.1 luarocks - name: uname -a run: uname -a From 26617d71a75554c5c06df203a042cb151fe2d2e3 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:38:48 +0100 Subject: [PATCH 21/55] GitHub Actions: sudo --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 440d924..2680559 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Dependencies - run: apt install lua5.1 + run: sudo apt-get install lua5.1 - name: uname -a run: uname -a @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Dependencies - run: apt install lua5.1 luarocks + run: sudo apt-get install lua5.1 luarocks - name: uname -a run: uname -a From 624b9539a7019132d6211cedf6fa366b7070657e Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:39:55 +0100 Subject: [PATCH 22/55] =?UTF-8?q?GitHub=20Actions:=20lua=20--version=20?= =?UTF-8?q?=E2=86=92=20lua=20-v?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2680559..fc58b1f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,8 +10,8 @@ jobs: - name: uname -a run: uname -a - - name: lua --version - run: lua --version + - name: Lua version + run: lua -v - name: Perform Check run: find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; @@ -24,8 +24,8 @@ jobs: - name: uname -a run: uname -a - - name: lua --version - run: lua --version + - name: Lua version + run: lua -v - name: Run Tests run: ./tests.sh From 04b5723db2fa73a62bcd8a47b450912aa3ccc573 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:43:02 +0100 Subject: [PATCH 23/55] GitHub Actions: sanity check --- .github/workflows/test.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fc58b1f..16ec4b5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,9 @@ jobs: run: lua -v - name: Perform Check - run: find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; + run: | + ls -la + find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; Busted: runs-on: ubuntu-latest steps: @@ -28,4 +30,6 @@ jobs: run: lua -v - name: Run Tests - run: ./tests.sh + run: | + ls -la + ./tests.sh From 37f25d40a112c1d20114d510e16819f859b42c27 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:45:31 +0100 Subject: [PATCH 24/55] GitHub Actions: Add Checkout action --- .github/workflows/test.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 16ec4b5..0e1ffc0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,10 @@ jobs: Syntax-Check: runs-on: ubuntu-latest steps: + # Checkout the git repo + - name: Checkout + uses: actions/checkout@v2 + - name: Install Dependencies run: sudo apt-get install lua5.1 @@ -20,6 +24,10 @@ jobs: Busted: runs-on: ubuntu-latest steps: + # Checkout the git repo + - name: Checkout + uses: actions/checkout@v2 + - name: Install Dependencies run: sudo apt-get install lua5.1 luarocks From 6f8c4d0c7c90772ad4476531bff95e75bbc0d607 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:47:21 +0100 Subject: [PATCH 25/55] GitHub Actions: Run tests --- .github/workflows/test.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0e1ffc0..310e676 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ jobs: uses: actions/checkout@v2 - name: Install Dependencies - run: sudo apt-get install lua5.1 + run: sudo apt-get --quiet install lua5.1 - name: uname -a run: uname -a @@ -18,9 +18,7 @@ jobs: run: lua -v - name: Perform Check - run: | - ls -la - find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; + run: find . -type f -name '*.lua' -not -path '*luarocks*' -not -path '*.git/*' -print0 | xargs -0 -n1 -P "$(nproc)" luac -p; Busted: runs-on: ubuntu-latest steps: @@ -29,7 +27,7 @@ jobs: uses: actions/checkout@v2 - name: Install Dependencies - run: sudo apt-get install lua5.1 luarocks + run: sudo apt-get --quiet install lua5.1 luarocks - name: uname -a run: uname -a @@ -38,6 +36,4 @@ jobs: run: lua -v - name: Run Tests - run: | - ls -la - ./tests.sh + run: ./tests.sh run From 73a9ff3d6061e52b0ca432e59e88c5bac9173f5d Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 18:49:05 +0100 Subject: [PATCH 26/55] GitHub Actions: tweak --- .github/workflows/test.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 310e676..2aa3597 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Install Dependencies + - name: Install apt dependencies run: sudo apt-get --quiet install lua5.1 - name: uname -a @@ -26,7 +26,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Install Dependencies + - name: Install apt dependencies run: sudo apt-get --quiet install lua5.1 luarocks - name: uname -a @@ -35,5 +35,8 @@ jobs: - name: Lua version run: lua -v + - name: Set up tests + run: ./tests.sh run + - name: Run Tests run: ./tests.sh run From e10dd1ff2e2ca730047fb6e440ebfa0b217feb65 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:03:40 +0100 Subject: [PATCH 27/55] Luacheck: start drafting config file --- .github/workflows/test.yml | 19 +++++++++++++++++++ .tests/luacheckrc | 29 +++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .tests/luacheckrc diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2aa3597..9c5d2f3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,3 +40,22 @@ jobs: - name: Run Tests run: ./tests.sh run + LuaCheck: + runs-on: ubuntu-latest + sets: + # Checkout the git repo + - name: Checkout + uses: actions/checkout@v2 + + - name: Install apt dependencies + run: sudo apt-get --quiet install lua5.1 lua-check + + - name: uname -a + run: uname -a + + - name: Lua version + run: lua -v + + - name: Run luacheck + run: luacheck --config .tests/luacheckrc . || true + diff --git a/.tests/luacheckrc b/.tests/luacheckrc new file mode 100644 index 0000000..36f9fd9 --- /dev/null +++ b/.tests/luacheckrc @@ -0,0 +1,29 @@ +quiet = 1 +codes = true + +exclude_files = { + ".luarocks/*" +} + + +ignore = {"631", "61[124]", "412", "21[123]"} + +-- Read-write globals (i.e. they can be defined) +globals = { + "worldedit", + "worldeditadditions", + "worldeditadditions_commands", + "worldeditadditions_core" +} +-- Read-only globals +read_globals = { + "minetest", + "vector", + "assert", + "bit", + "it", + "describe", + "bonemeal", + "dofile" +} +std = "max" From 910d4b036f48d6d8d6cbb61bdb57e4f0ea2a19eb Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:03:54 +0100 Subject: [PATCH 28/55] maze2d: squash another undefined variable --- worldeditadditions/lib/maze2d.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions/lib/maze2d.lua b/worldeditadditions/lib/maze2d.lua index 2a3023c..8fc95ea 100644 --- a/worldeditadditions/lib/maze2d.lua +++ b/worldeditadditions/lib/maze2d.lua @@ -17,7 +17,7 @@ local function printspace(space, w, h) end local function generate_maze(seed, width, height, path_length, path_width) - start_time = worldeditadditions.get_ms_time() + local start_time = worldeditadditions.get_ms_time() if not path_length then path_length = 2 end if not path_width then path_width = 1 end From 082f491fa6ebe33363ea39bee14343b561c5c43e Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:04:21 +0100 Subject: [PATCH 29/55] add comment --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9c5d2f3..423762a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -56,6 +56,7 @@ jobs: - name: Lua version run: lua -v + # luacheck throws lots of errors at the moment, so don't fail the build - name: Run luacheck run: luacheck --config .tests/luacheckrc . || true From fd2ae786254b98b769c4b80d7e3aed10c92a6db2 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:19:09 +0100 Subject: [PATCH 30/55] typo --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 423762a..d5adead 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,7 +42,7 @@ jobs: run: ./tests.sh run LuaCheck: runs-on: ubuntu-latest - sets: + steps: # Checkout the git repo - name: Checkout uses: actions/checkout@v2 From c6bae3b7e0f85da1878bab418ba73c578dfee2c0 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:44:02 +0100 Subject: [PATCH 31/55] //erode river: fix redefining i in nested loop --- worldeditadditions/lib/erode/river.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/worldeditadditions/lib/erode/river.lua b/worldeditadditions/lib/erode/river.lua index df200a4..4d4fda8 100644 --- a/worldeditadditions/lib/erode/river.lua +++ b/worldeditadditions/lib/erode/river.lua @@ -80,14 +80,14 @@ function worldeditadditions.erode.river(heightmap_initial, heightmap, heightmap_ local action = "none" if not isedge then if sides_higher > sides_lower then - for i,sidecount in ipairs(params.raise_sides) do + for _,sidecount in ipairs(params.raise_sides) do if sidecount == sides_higher then action = "fill" break end end else - for i,sidecount in ipairs(params.lower_sides) do + for _i,sidecount in ipairs(params.lower_sides) do if sidecount == sides_lower then action = "remove" break @@ -109,10 +109,10 @@ function worldeditadditions.erode.river(heightmap_initial, heightmap, heightmap_ end end - for i,hi in ipairs(fill) do + for _i,hi in ipairs(fill) do heightmap[hi] = heightmap[hi] + 1 end - for i,hi in ipairs(remove) do + for _i,hi in ipairs(remove) do heightmap[hi] = heightmap[hi] - 1 end From f37a2aabcf1b5e14ea19350199859bc660de0a0c Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:45:09 +0100 Subject: [PATCH 32/55] //forest: Fix redefining variable i in loop --- worldeditadditions/lib/forest.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worldeditadditions/lib/forest.lua b/worldeditadditions/lib/forest.lua index 5294174..c0d3022 100644 --- a/worldeditadditions/lib/forest.lua +++ b/worldeditadditions/lib/forest.lua @@ -40,7 +40,7 @@ function worldeditadditions.forest(pos1, pos2, density_multiplier, sapling_weigh local did_grow = false local new_id_at_pos local new_name_at_pos - for i=1,100 do + for attempt_number=1,100 do bonemeal:on_use( { x = x, y = y, z = z }, 4, @@ -55,7 +55,7 @@ function worldeditadditions.forest(pos1, pos2, density_multiplier, sapling_weigh if not group_cache[new_id_at_pos] then did_grow = true -- Log the number of attempts it took to grow - table.insert(stats.attempts, i) + table.insert(stats.attempts, attempt_number) -- Update the running total of saplings that grew if not stats.placed[node_id] then stats.placed[node_id] = 0 From 1f4a115063914ed32a0c75cb55d2f35227a0c7a0 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:46:33 +0100 Subject: [PATCH 33/55] //maze3d: Fix accidental global variable definition --- worldeditadditions/lib/maze3d.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/worldeditadditions/lib/maze3d.lua b/worldeditadditions/lib/maze3d.lua index fe84aa4..42318e2 100644 --- a/worldeditadditions/lib/maze3d.lua +++ b/worldeditadditions/lib/maze3d.lua @@ -5,7 +5,7 @@ ---------------------------------- -- function to print out the world ---------------------------------- -function printspace3d(space, w, h, d) +local function printspace3d(space, w, h, d) for z = 0, d - 1, 1 do for y = 0, h - 1, 1 do local line = "" @@ -18,9 +18,6 @@ function printspace3d(space, w, h, d) end end --- Initialise the world -start_time = worldeditadditions.get_ms_time() - local function generate_maze3d(seed, width, height, depth, path_length, path_width, path_depth) if not path_length then path_length = 2 end From 51e1e7dcbd3e34158fcd500f173daac8ebaa6000 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:47:21 +0100 Subject: [PATCH 34/55] noise.params_apply_default: Fix shadowing variable --- worldeditadditions/lib/noise/params_apply_default.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions/lib/noise/params_apply_default.lua b/worldeditadditions/lib/noise/params_apply_default.lua index cd00852..e1121ad 100644 --- a/worldeditadditions/lib/noise/params_apply_default.lua +++ b/worldeditadditions/lib/noise/params_apply_default.lua @@ -37,7 +37,7 @@ function worldeditadditions.noise.params_apply_default(params) local default_copy = wea.table.shallowcopy(params_default) -- Keyword support - for i, keyword in ipairs(wea.noise.engines.available) do + for _i, keyword in ipairs(wea.noise.engines.available) do if params_el[keyword] ~= nil then params_el.algorithm = keyword end From 54d0f5a3a31c968f07c5f57a5a3da9a76d350596 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:48:10 +0100 Subject: [PATCH 35/55] run2d: Fix accidental redefining global variable --- worldeditadditions/lib/noise/run2d.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worldeditadditions/lib/noise/run2d.lua b/worldeditadditions/lib/noise/run2d.lua index d285a3b..001f8ce 100644 --- a/worldeditadditions/lib/noise/run2d.lua +++ b/worldeditadditions/lib/noise/run2d.lua @@ -48,8 +48,8 @@ function worldeditadditions.noise.run2d(pos1, pos2, noise_params) ) if not success then return success, message end - - local success, stats = wea.apply_heightmap_changes( + local stats + success, stats = wea.apply_heightmap_changes( pos1, pos2, area, data, heightmap_old, heightmap_new, From 64ed01132eca1de1939b35ae36953338c8803aff Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:49:11 +0100 Subject: [PATCH 36/55] scale_down: fix redefining posi_copy --- worldeditadditions/lib/scale_down.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions/lib/scale_down.lua b/worldeditadditions/lib/scale_down.lua index 7bc95fc..5bca63a 100644 --- a/worldeditadditions/lib/scale_down.lua +++ b/worldeditadditions/lib/scale_down.lua @@ -80,7 +80,7 @@ function worldeditadditions.scale_down(pos1, pos2, scale, anchor) if anchor.y < 0 then posi_copy.y = size.y - posi_copy.y end if anchor.z < 0 then posi_copy.z = size.z - posi_copy.z end - local posi_copy = vector.add(pos1, posi_copy) + posi_copy = vector.add(pos1, posi_copy) local i_source = area:index(x, y, z) local i_target = area:index(posi_copy.x, posi_copy.y, posi_copy.z) From 3c414f2dbd76cc911e902d360a48c3a2925249a4 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:52:36 +0100 Subject: [PATCH 37/55] Fix more issues discovered by luacheck --- .tests/luacheckrc | 10 ++++++++-- worldeditadditions/utils/format/human_size.lua | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.tests/luacheckrc b/.tests/luacheckrc index 36f9fd9..7c036ae 100644 --- a/.tests/luacheckrc +++ b/.tests/luacheckrc @@ -2,11 +2,17 @@ quiet = 1 codes = true exclude_files = { - ".luarocks/*" + ".luarocks/*", + "worldeditadditions/utils/bit.lua" } -ignore = {"631", "61[124]", "412", "21[123]"} +ignore = { + "631", "61[124]", + "412", + "321/bit", + "21[123]" +} -- Read-write globals (i.e. they can be defined) globals = { diff --git a/worldeditadditions/utils/format/human_size.lua b/worldeditadditions/utils/format/human_size.lua index 2403ff0..7bb600c 100644 --- a/worldeditadditions/utils/format/human_size.lua +++ b/worldeditadditions/utils/format/human_size.lua @@ -5,7 +5,7 @@ -- @param decimals number The number of decimal places to show. -- @return string A formatted string that represents the given input number. function worldeditadditions.format.human_size(n, decimals) - sizes = { "", "K", "M", "G", "T", "P", "E", "Y", "Z" } + local sizes = { "", "K", "M", "G", "T", "P", "E", "Y", "Z" } local factor = math.floor((#tostring(n) - 1) / 3) local multiplier = 10^(decimals or 0) local result = math.floor(0.5 + (n / math.pow(1000, factor)) * multiplier) / multiplier From a8e0a3088b697b27aca0b0061a30fb90c7ccc20e Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:53:29 +0100 Subject: [PATCH 38/55] lru_benchmark: fix luacheck errors --- worldeditadditions/utils/lru_benchmark.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worldeditadditions/utils/lru_benchmark.lua b/worldeditadditions/utils/lru_benchmark.lua index 0f1d201..4477c70 100644 --- a/worldeditadditions/utils/lru_benchmark.lua +++ b/worldeditadditions/utils/lru_benchmark.lua @@ -16,7 +16,7 @@ local values = { } -- From http://lua-users.org/wiki/SimpleRound -function round(num, numDecimalPlaces) +local function round(num, numDecimalPlaces) local mult = 10^(numDecimalPlaces or 0) return math.floor(num * mult + 0.5) / mult end @@ -37,7 +37,7 @@ end local values_count = #values -function test(size) +local function test(size) local cpu_start = os.clock() From 3ac0fa14f90d8900be33563a62ded8bc909d8ab1 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:54:13 +0100 Subject: [PATCH 39/55] is_airlike: Fix accessing undefined global variable --- worldeditadditions/utils/node_identification.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions/utils/node_identification.lua b/worldeditadditions/utils/node_identification.lua index 9fe3324..bcf855b 100644 --- a/worldeditadditions/utils/node_identification.lua +++ b/worldeditadditions/utils/node_identification.lua @@ -25,7 +25,7 @@ function worldeditadditions.is_airlike(id) return true end -- Just in case - if worldeditadditions.str_starts(this_node_name, "wielded_light") then + if worldeditadditions.str_starts(name, "wielded_light") then return true end -- Just in case From 05eaf0191274841da9573df74aa47e7e3c25f7dc Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:54:57 +0100 Subject: [PATCH 40/55] nodes.lua: fix shadowing definition of loop variable i on line 22 --- worldeditadditions/utils/nodes.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions/utils/nodes.lua b/worldeditadditions/utils/nodes.lua index 222e0a4..70ea40c 100644 --- a/worldeditadditions/utils/nodes.lua +++ b/worldeditadditions/utils/nodes.lua @@ -21,7 +21,7 @@ function worldeditadditions.unwind_node_list(list) local result = {} for i,item in ipairs(list) do local node_id = minetest.get_content_id(item.node) - for i = 1, item.weight do + for _i = 1, item.weight do table.insert(result, node_id) end end From 0164a9b9eb30d181d974d3f3ee07e2bb9e506d7d Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:56:01 +0100 Subject: [PATCH 41/55] wea.parse.map: fix autoconverting to number / bool --- worldeditadditions/utils/parse/map.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions/utils/parse/map.lua b/worldeditadditions/utils/parse/map.lua index 94bc360..e2b28ca 100644 --- a/worldeditadditions/utils/parse/map.lua +++ b/worldeditadditions/utils/parse/map.lua @@ -21,7 +21,7 @@ function worldeditadditions.parse.map(params_text, keywords) -- Look for bools if part_converted == "true" then part_converted = true end if part_converted == "false" then part_converted = false end - result[last_key] = part + result[last_key] = part_converted mode = "KEY" else last_key = part From f0e1111b7c858aa0be7a2fcc871004dedad80fba Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:56:44 +0100 Subject: [PATCH 42/55] tokenise_commands: fix luacheck issue --- worldeditadditions/utils/parse/tokenise_commands.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions/utils/parse/tokenise_commands.lua b/worldeditadditions/utils/parse/tokenise_commands.lua index 2a96746..eb44dbb 100644 --- a/worldeditadditions/utils/parse/tokenise_commands.lua +++ b/worldeditadditions/utils/parse/tokenise_commands.lua @@ -40,7 +40,7 @@ local function tokenise(str) -- Decrease the nested depth nested_depth = nested_depth - 1 -- Pop the start of this block off the stack and find this block's contents - block_start = table.remove(nested_stack, #nested_stack) + local block_start = table.remove(nested_stack, #nested_stack) local substr = str:sub(block_start, nextpos - 1) if #substr > 0 and nested_depth == 0 then table.insert(result, substr) end elseif char == "{" then From 8c76b3b7606e74ce3e1dc8b17cf2e8705b7aefb3 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:57:16 +0100 Subject: [PATCH 43/55] Queue: fix accessing undefined variable result --- worldeditadditions/utils/queue.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions/utils/queue.lua b/worldeditadditions/utils/queue.lua index 0bbfafc..af1817f 100644 --- a/worldeditadditions/utils/queue.lua +++ b/worldeditadditions/utils/queue.lua @@ -6,7 +6,7 @@ local Queue = {} Queue.__index = Queue function Queue.new() - result = { first = 0, last = -1, items = {} } + local result = { first = 0, last = -1, items = {} } setmetatable(result, Queue) return result end From ee561cd6e4aee057185fda9c38bcb75a33eb1dd3 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:58:23 +0100 Subject: [PATCH 44/55] //convolve: fix luacheck issue --- .tests/luacheckrc | 1 + worldeditadditions_commands/commands/convolve.lua | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.tests/luacheckrc b/.tests/luacheckrc index 7c036ae..c3a1473 100644 --- a/.tests/luacheckrc +++ b/.tests/luacheckrc @@ -9,6 +9,7 @@ exclude_files = { ignore = { "631", "61[124]", + "542", "412", "321/bit", "21[123]" diff --git a/worldeditadditions_commands/commands/convolve.lua b/worldeditadditions_commands/commands/convolve.lua index da12810..22ddf79 100644 --- a/worldeditadditions_commands/commands/convolve.lua +++ b/worldeditadditions_commands/commands/convolve.lua @@ -58,7 +58,8 @@ worldedit.register_command("convolve", { kernel_size[0] = kernel_height kernel_size[1] = kernel_width - local success, stats = worldeditadditions.convolve( + local stats + success, stats = worldeditadditions.convolve( worldedit.pos1[name], worldedit.pos2[name], kernel, kernel_size ) From 9ccd62845fd6d38976ba849298f2b5f9a7785e93 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 19:59:34 +0100 Subject: [PATCH 45/55] //line: correctly return error in parsing function --- worldeditadditions_commands/commands/line.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/worldeditadditions_commands/commands/line.lua b/worldeditadditions_commands/commands/line.lua index 644fafa..3bb6d00 100644 --- a/worldeditadditions_commands/commands/line.lua +++ b/worldeditadditions_commands/commands/line.lua @@ -24,8 +24,7 @@ worldedit.register_command("line", { replace_node = worldedit.normalize_nodename(replace_node) if not replace_node then - worldedit.player_notify(name, "Error: Invalid node name.") - return false + return false, "Error: Invalid node name '"..replace_node.."'." end return true, replace_node, radius From 47303acac16fd98267d84034fcec17899fb34352 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 20:00:41 +0100 Subject: [PATCH 46/55] //convolve: fix wea.convolve returns false, then return the associated error message --- worldeditadditions_commands/commands/convolve.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/worldeditadditions_commands/commands/convolve.lua b/worldeditadditions_commands/commands/convolve.lua index 22ddf79..609f86d 100644 --- a/worldeditadditions_commands/commands/convolve.lua +++ b/worldeditadditions_commands/commands/convolve.lua @@ -63,6 +63,7 @@ worldedit.register_command("convolve", { worldedit.pos1[name], worldedit.pos2[name], kernel, kernel_size ) + if not success then return success, stats end local time_taken = worldeditadditions.get_ms_time() - start_time From 1c8d572bb8bf088626da695b5b41e5cdc488d880 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 20:01:38 +0100 Subject: [PATCH 47/55] //airapply: fix undefined variables --- worldeditadditions_commands/commands/meta/airapply.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worldeditadditions_commands/commands/meta/airapply.lua b/worldeditadditions_commands/commands/meta/airapply.lua index 83324e2..5cd3331 100644 --- a/worldeditadditions_commands/commands/meta/airapply.lua +++ b/worldeditadditions_commands/commands/meta/airapply.lua @@ -43,7 +43,7 @@ worldedit.register_command("airapply", { end, func = function(name, cmd, args_parsed) if not minetest.check_player_privs(name, cmd.privs) then - return false, "Your privileges are insufficient to execute the command '"..cmd_name.."'." + return false, "Your privileges are insufficient to execute the command '"..cmd.."'." end local pos1, pos2 = worldeditadditions.Vector3.sort( @@ -56,7 +56,7 @@ worldedit.register_command("airapply", { pos1, pos2, function() cmd.func(name, worldeditadditions.table.unpack(args_parsed)) - end, args + end, args_parsed ) From 23e08c56931e738bbdc3cd991c7e2116a5b1b365 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 20:03:16 +0100 Subject: [PATCH 48/55] //multi: luacheck fix --- worldeditadditions_commands/commands/meta/multi.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions_commands/commands/meta/multi.lua b/worldeditadditions_commands/commands/meta/multi.lua index 61ae9b7..038d6d7 100644 --- a/worldeditadditions_commands/commands/meta/multi.lua +++ b/worldeditadditions_commands/commands/meta/multi.lua @@ -12,7 +12,7 @@ local function explode(delim, str) return function() if is_done then return end - local result = nil + local result local loc = string.find(str, delim, ll, true) -- find the next d in the string if loc ~= nil then -- if "not not" found then.. result = string.sub(str, ll, loc - 1) -- Save it in our array. From c14bb40f7e26a4f35970893767ebfb3b315f84aa Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 20:03:31 +0100 Subject: [PATCH 49/55] //ellipsoidapply: undefined variable fixes --- worldeditadditions_commands/commands/meta/ellipsoidapply.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worldeditadditions_commands/commands/meta/ellipsoidapply.lua b/worldeditadditions_commands/commands/meta/ellipsoidapply.lua index 5400488..83f00a1 100644 --- a/worldeditadditions_commands/commands/meta/ellipsoidapply.lua +++ b/worldeditadditions_commands/commands/meta/ellipsoidapply.lua @@ -45,14 +45,14 @@ worldedit.register_command("ellipsoidapply", { end, func = function(name, cmd, args_parsed) if not minetest.check_player_privs(name, cmd.privs) then - return false, "Your privileges are insufficient to execute the command '"..cmd_name.."'." + return false, "Your privileges are insufficient to execute the command '"..cmd.."'." end local success, stats_time = worldeditadditions.ellipsoidapply( worldedit.pos1[name], worldedit.pos2[name], function() cmd.func(name, worldeditadditions.table.unpack(args_parsed)) - end, args + end, args_parsed ) local time_overhead = 100 - worldeditadditions.round((stats_time.fn / stats_time.all) * 100, 3) From 655d9ebac94b1eeb85251247030f20e2090a124d Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 20:07:08 +0100 Subject: [PATCH 50/55] //many, //multi, parse_reference: various luacheck fixes --- worldeditadditions_commands/commands/meta/many.lua | 3 ++- worldeditadditions_commands/commands/meta/multi.lua | 2 -- worldeditadditions_commands/doc/parse_reference.lua | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/worldeditadditions_commands/commands/meta/many.lua b/worldeditadditions_commands/commands/meta/many.lua index d5165f1..49ecd05 100644 --- a/worldeditadditions_commands/commands/meta/many.lua +++ b/worldeditadditions_commands/commands/meta/many.lua @@ -3,6 +3,7 @@ -- explode(separator, string) -- From http://lua-users.org/wiki/SplitJoin +-- TODO: Refactor this to use wea.split instead local function explode(delim, str) local ll, is_done local delim_length = string.len(delim) @@ -12,7 +13,7 @@ local function explode(delim, str) return function() if is_done then return end - local result = nil + local result local loc = string.find(str, delim, ll, true) -- find the next d in the string if loc ~= nil then -- if "not not" found then.. result = string.sub(str, ll, loc - 1) -- Save it in our array. diff --git a/worldeditadditions_commands/commands/meta/multi.lua b/worldeditadditions_commands/commands/meta/multi.lua index 038d6d7..34d26c0 100644 --- a/worldeditadditions_commands/commands/meta/multi.lua +++ b/worldeditadditions_commands/commands/meta/multi.lua @@ -35,8 +35,6 @@ minetest.register_chatcommand("/multi", { params_text = worldeditadditions.trim(params_text) if #params_text == 0 then return false, "Error: No commands specified, so there's nothing to do." end - - local i = 1 -- For feedback only local master_start_time = worldeditadditions.get_ms_time() local times = {} diff --git a/worldeditadditions_commands/doc/parse_reference.lua b/worldeditadditions_commands/doc/parse_reference.lua index 5784124..3dea8e1 100644 --- a/worldeditadditions_commands/doc/parse_reference.lua +++ b/worldeditadditions_commands/doc/parse_reference.lua @@ -37,7 +37,7 @@ function worldeditadditions.doc.parse_reference() function(item, i) return item.level ~= 2 end ) for i,value in ipairs(headings) do - print(i, "level", level, "heading", heading, "text", text) + print(i, "level", value.level, "heading", value.heading, "text", value.text) end end From e16fa0f5c8877f6b430c359af77eb17d982e10a2 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 30 Jul 2021 21:21:50 +0100 Subject: [PATCH 51/55] Move luacheck config file to standard location --- .github/workflows/test.yml | 2 +- .tests/luacheckrc => .luacheckrc | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename .tests/luacheckrc => .luacheckrc (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d5adead..a9cd307 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -58,5 +58,5 @@ jobs: # luacheck throws lots of errors at the moment, so don't fail the build - name: Run luacheck - run: luacheck --config .tests/luacheckrc . || true + run: luacheck . || true diff --git a/.tests/luacheckrc b/.luacheckrc similarity index 100% rename from .tests/luacheckrc rename to .luacheckrc From 45def5329432c3cb8bcecc5f0cc3532c046b2130 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sat, 31 Jul 2021 16:03:04 +0100 Subject: [PATCH 52/55] various commands: Upgrade to use wea.split_shell --- worldeditadditions/utils/strings/split_shell.lua | 9 +++++++-- worldeditadditions_commands/commands/bonemeal.lua | 2 +- worldeditadditions_commands/commands/convolve.lua | 3 ++- worldeditadditions_commands/commands/ellipsoid.lua | 2 +- worldeditadditions_commands/commands/forest.lua | 2 +- worldeditadditions_commands/commands/layers.lua | 2 +- worldeditadditions_commands/commands/maze.lua | 2 +- worldeditadditions_commands/commands/overlay.lua | 2 +- worldeditadditions_commands/commands/replacemix.lua | 2 +- worldeditadditions_commands/commands/scale.lua | 2 +- worldeditadditions_commands/commands/torus.lua | 2 +- 11 files changed, 18 insertions(+), 12 deletions(-) diff --git a/worldeditadditions/utils/strings/split_shell.lua b/worldeditadditions/utils/strings/split_shell.lua index 32d4d0d..cb9cab7 100644 --- a/worldeditadditions/utils/strings/split_shell.lua +++ b/worldeditadditions/utils/strings/split_shell.lua @@ -1,3 +1,4 @@ +-- worldeditadditions = { modpath="/home/sbrl/.minetest/worlds/Mod-Sandbox/worldmods/WorldEditAdditions/worldeditadditions/" } local table_map = dofile(worldeditadditions.modpath.."/utils/tables/table_map.lua") local function is_whitespace(char) @@ -21,6 +22,8 @@ local function split_shell(text) if i < text_length then nextchar = text:sub(i+1, i+1) end if i+1 < text_length then nextnextchar = text:sub(i+2, i+2) end + print("mode", mode, "prevchar", "curchar", curchar, "nextchar", nextchar) + if mode == "NORMAL" then if is_whitespace(curchar) and #acc > 0 then table.insert(result, table.concat(acc, "")) @@ -35,9 +38,10 @@ local function split_shell(text) table.insert(acc, curchar) end elseif mode == "INSIDE_QUOTES_DOUBLE" then - if curchar == "\"" and prevchar ~= "\\" and is_whitespace(nextchar) then + if curchar == "\"" and prevchar ~= "\\" and (is_whitespace(nextchar) or #nextchar == 0) then -- It's the end of a quote! mode = "NORMAL" + elseif (curchar == "\\" and ( nextchar ~= "\"" or (nextchar == "\"" and not is_whitespace(nextnextchar)) @@ -71,7 +75,7 @@ end return split_shell --- function test(text) +-- local function test(text) -- print("Source", text) -- for i,value in ipairs(split_shell(text)) do -- print("i", i, "→", value) @@ -80,6 +84,7 @@ return split_shell -- end -- -- test("yay yay yay") +-- test("dirt \"snow block\"") -- test("yay \"yay yay\" yay") -- test("yay \"yay\\\" yay\" yay") -- test("yay \"yay 'inside quotes' yay\\\"\" yay") diff --git a/worldeditadditions_commands/commands/bonemeal.lua b/worldeditadditions_commands/commands/bonemeal.lua index 088780f..505ae99 100644 --- a/worldeditadditions_commands/commands/bonemeal.lua +++ b/worldeditadditions_commands/commands/bonemeal.lua @@ -15,7 +15,7 @@ worldedit.register_command("bonemeal", { params_text = "1" end - local parts = worldeditadditions.split(params_text, "%s+", false) + local parts = worldeditadditions.split_shell(params_text, "%s+", false) local strength = 1 local chance = 1 diff --git a/worldeditadditions_commands/commands/convolve.lua b/worldeditadditions_commands/commands/convolve.lua index 609f86d..1ad1171 100644 --- a/worldeditadditions_commands/commands/convolve.lua +++ b/worldeditadditions_commands/commands/convolve.lua @@ -11,7 +11,8 @@ worldedit.register_command("convolve", { parse = function(params_text) if not params_text then params_text = "" end - local parts = worldeditadditions.split(params_text, "%s+", false) + -- local parts = worldeditadditions.split(params_text, "%s+", false) + local parts = worldeditadditions.split_shell(params_text) local kernel_name = "gaussian" local width = 5 diff --git a/worldeditadditions_commands/commands/ellipsoid.lua b/worldeditadditions_commands/commands/ellipsoid.lua index 97d3bfd..efa4ebf 100644 --- a/worldeditadditions_commands/commands/ellipsoid.lua +++ b/worldeditadditions_commands/commands/ellipsoid.lua @@ -5,7 +5,7 @@ -- ███████ ███████ ███████ ██ ██ ███████ ██████ ██ ██████ local wea = worldeditadditions local function parse_params_ellipsoid(params_text) - local parts = wea.split(params_text, "%s+", false) + local parts = wea.split_shell(params_text) if #parts < 4 then return false, "Error: Not enough arguments. Expected \" [h[ollow]]\"." diff --git a/worldeditadditions_commands/commands/forest.lua b/worldeditadditions_commands/commands/forest.lua index 14810f6..29167f9 100644 --- a/worldeditadditions_commands/commands/forest.lua +++ b/worldeditadditions_commands/commands/forest.lua @@ -18,7 +18,7 @@ worldedit.register_command("forest", { end local success, sapling_list = worldeditadditions.parse.weighted_nodes( - worldeditadditions.split(params_text, "%s+", false), + worldeditadditions.split_shell(params_text), false, function(name) return worldedit.normalize_nodename( diff --git a/worldeditadditions_commands/commands/layers.lua b/worldeditadditions_commands/commands/layers.lua index 28dd8da..ae09158 100644 --- a/worldeditadditions_commands/commands/layers.lua +++ b/worldeditadditions_commands/commands/layers.lua @@ -14,7 +14,7 @@ worldedit.register_command("layers", { end local success, node_list = worldeditadditions.parse.weighted_nodes( - worldeditadditions.split(params_text, "%s+", false), + worldeditadditions.split_shell(params_text), true ) return success, node_list diff --git a/worldeditadditions_commands/commands/maze.lua b/worldeditadditions_commands/commands/maze.lua index 48f626d..a02c7de 100644 --- a/worldeditadditions_commands/commands/maze.lua +++ b/worldeditadditions_commands/commands/maze.lua @@ -5,7 +5,7 @@ local function parse_params_maze(params_text, is_3d) return false, "No arguments specified" end - local parts = worldeditadditions.split(params_text, "%s+", false) + local parts = worldeditadditions.split_shell(params_text) local replace_node = parts[1] local seed = os.time() diff --git a/worldeditadditions_commands/commands/overlay.lua b/worldeditadditions_commands/commands/overlay.lua index ad0ddf5..e7f3d0f 100644 --- a/worldeditadditions_commands/commands/overlay.lua +++ b/worldeditadditions_commands/commands/overlay.lua @@ -10,7 +10,7 @@ worldedit.register_command("overlay", { require_pos = 2, parse = function(params_text) local success, node_list = worldeditadditions.parse.weighted_nodes( - worldeditadditions.split(params_text, "%s+", false) + worldeditadditions.split_shell(params_text) ) return success, node_list end, diff --git a/worldeditadditions_commands/commands/replacemix.lua b/worldeditadditions_commands/commands/replacemix.lua index 5eaa61a..085e596 100644 --- a/worldeditadditions_commands/commands/replacemix.lua +++ b/worldeditadditions_commands/commands/replacemix.lua @@ -15,7 +15,7 @@ worldedit.register_command("replacemix", { return false, "Error: No arguments specified" end - local parts = wea.split(params_text, "%s+", false) + local parts = wea.split_shell(params_text) local target_node = nil local target_node_chance = 1 diff --git a/worldeditadditions_commands/commands/scale.lua b/worldeditadditions_commands/commands/scale.lua index efebcaf..3076386 100644 --- a/worldeditadditions_commands/commands/scale.lua +++ b/worldeditadditions_commands/commands/scale.lua @@ -30,7 +30,7 @@ worldedit.register_command("scale", { parse = function(params_text) if not params_text then params_text = "" end - local parts = worldeditadditions.split(params_text, "%s+", false) + local parts = worldeditadditions.split_shell(params_text) local scale = vector.new(1, 1, 1) local anchor = vector.new(1, 1, 1) diff --git a/worldeditadditions_commands/commands/torus.lua b/worldeditadditions_commands/commands/torus.lua index 6131639..4ae2b5c 100644 --- a/worldeditadditions_commands/commands/torus.lua +++ b/worldeditadditions_commands/commands/torus.lua @@ -4,7 +4,7 @@ -- ██ ██ ██ ██ ██ ██ ██ ██ -- ██ ██████ ██ ██ ██████ ███████ local function parse_params_torus(params_text) - local parts = worldeditadditions.split(params_text, "%s+", false) + local parts = worldeditadditions.split_shell(params_text) if #parts < 1 then return false, "Error: No replace_node specified." From 38b095d33e2ac8f59539893884267dea70cf1f84 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sat, 31 Jul 2021 16:06:37 +0100 Subject: [PATCH 53/55] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6d2d61..dc8839b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ Note to self: See the bottom of this file for the release template text. - Add `//sfactor` (_selection factor_) - Selection Tools by @VorTechnix are finished for now. - Add `mface` (_measure facing_), `midpos` (_measure middle position_), `msize` (_measure size_), `mtrig` (_measure trigonometry_) - Measuring Tools implemented by @VorTechnix. - Add `//airapply` for applying commands only to air nodes in the defined region + - Use [luacheck](https://github.com/mpeterv/luacheck) to find and fix a large number of bugs and other issues + - Multiple commands: Allow using quotes (`"thing"`, `'thing'`) to quote values when splitting ## v1.12: The selection tools update (26th June 2021) From 07c55dc7409df5fff1fa2249697048320fa6a17a Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sat, 31 Jul 2021 16:07:48 +0100 Subject: [PATCH 54/55] split_shell: comment debug also, in 45def53 we fixed a bug with quotes being left behind at the and of a string --- worldeditadditions/utils/strings/split_shell.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions/utils/strings/split_shell.lua b/worldeditadditions/utils/strings/split_shell.lua index cb9cab7..c801bdf 100644 --- a/worldeditadditions/utils/strings/split_shell.lua +++ b/worldeditadditions/utils/strings/split_shell.lua @@ -22,7 +22,7 @@ local function split_shell(text) if i < text_length then nextchar = text:sub(i+1, i+1) end if i+1 < text_length then nextnextchar = text:sub(i+2, i+2) end - print("mode", mode, "prevchar", "curchar", curchar, "nextchar", nextchar) + print("mode", mode, "prevchar", prevchar, "curchar", curchar, "nextchar", nextchar) if mode == "NORMAL" then if is_whitespace(curchar) and #acc > 0 then From a9b746986a9668b979a7b77312929ad72dc2d587 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sat, 31 Jul 2021 16:08:01 +0100 Subject: [PATCH 55/55] fixup --- worldeditadditions/utils/strings/split_shell.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldeditadditions/utils/strings/split_shell.lua b/worldeditadditions/utils/strings/split_shell.lua index c801bdf..ca8e1ba 100644 --- a/worldeditadditions/utils/strings/split_shell.lua +++ b/worldeditadditions/utils/strings/split_shell.lua @@ -22,7 +22,7 @@ local function split_shell(text) if i < text_length then nextchar = text:sub(i+1, i+1) end if i+1 < text_length then nextnextchar = text:sub(i+2, i+2) end - print("mode", mode, "prevchar", prevchar, "curchar", curchar, "nextchar", nextchar) + -- print("mode", mode, "prevchar", prevchar, "curchar", curchar, "nextchar", nextchar) if mode == "NORMAL" then if is_whitespace(curchar) and #acc > 0 then