From db7b20d4852771abcb7404c785aff7eda4d07d8f Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Mon, 28 Jun 2021 00:56:29 +0100 Subject: [PATCH] Refactor table functions into subtable of wea Also, you can return a value from dofile()!!!! This changes everything. --- worldeditadditions/lib/conv/conv.lua | 2 +- worldeditadditions/lib/erode/erode.lua | 2 +- worldeditadditions/lib/erode/river.lua | 4 +-- worldeditadditions/lib/erode/snowballs.lua | 2 +- worldeditadditions/lib/noise/noise2d.lua | 2 +- worldeditadditions/lib/noise/noise_params.lua | 4 +-- worldeditadditions/lib/scale_down.lua | 4 +-- worldeditadditions/lib/subdivide.lua | 4 +-- worldeditadditions/utils/axes.lua | 2 +- worldeditadditions/utils/mesh.lua | 2 +- worldeditadditions/utils/numbers.lua | 2 +- worldeditadditions/utils/tables/init.lua | 25 ++++++++++--------- .../utils/tables/{sets.lua => makeset.lua} | 14 +++++++---- .../utils/tables/shallowcopy.lua | 4 ++- .../utils/tables/table_apply.lua | 4 ++- .../utils/tables/table_contains.lua | 9 ++----- .../utils/tables/table_filter.lua | 4 ++- .../utils/tables/table_get_last.lua | 14 +++++++++-- worldeditadditions/utils/tables/table_map.lua | 4 ++- .../utils/tables/table_tostring.lua | 4 ++- .../utils/tables/table_unique.lua | 4 ++- .../utils/tables/table_unpack.lua | 4 ++- worldeditadditions/utils/terrain.lua | 2 +- .../commands/ellipsoid.lua | 4 +-- worldeditadditions_commands/commands/maze.lua | 2 +- .../commands/meta/ellipsoidapply.lua | 2 +- .../commands/meta/subdivide.lua | 4 +-- .../commands/selectors/smake.lua | 6 ++--- .../commands/torus.lua | 4 +-- .../doc/parse_reference.lua | 2 +- 30 files changed, 85 insertions(+), 61 deletions(-) rename worldeditadditions/utils/tables/{sets.lua => makeset.lua} (52%) diff --git a/worldeditadditions/lib/conv/conv.lua b/worldeditadditions/lib/conv/conv.lua index 52818f8..0330f95 100644 --- a/worldeditadditions/lib/conv/conv.lua +++ b/worldeditadditions/lib/conv/conv.lua @@ -58,7 +58,7 @@ function worldeditadditions.convolve(pos1, pos2, kernel, kernel_size) local node_id_air = minetest.get_content_id("air") local heightmap, heightmap_size = worldeditadditions.make_heightmap(pos1, pos2, manip, area, data) - local heightmap_conv = worldeditadditions.shallowcopy(heightmap) + local heightmap_conv = worldeditadditions.table.shallowcopy(heightmap) worldeditadditions.conv.convolve( heightmap_conv, diff --git a/worldeditadditions/lib/erode/erode.lua b/worldeditadditions/lib/erode/erode.lua index 76bd0e5..7c263b6 100644 --- a/worldeditadditions/lib/erode/erode.lua +++ b/worldeditadditions/lib/erode/erode.lua @@ -18,7 +18,7 @@ function worldeditadditions.erode.run(pos1, pos2, algorithm, params) local region_height = (pos2.y - pos1.y) + 1 local heightmap = worldeditadditions.make_heightmap(pos1, pos2, manip, area, data) - local heightmap_eroded = worldeditadditions.shallowcopy(heightmap) + local heightmap_eroded = worldeditadditions.table.shallowcopy(heightmap) -- print("[erode.run] algorithm: "..algorithm..", params:"); -- print(worldeditadditions.format.map(params)) diff --git a/worldeditadditions/lib/erode/river.lua b/worldeditadditions/lib/erode/river.lua index 9c6ea3f..c3d033c 100644 --- a/worldeditadditions/lib/erode/river.lua +++ b/worldeditadditions/lib/erode/river.lua @@ -5,7 +5,7 @@ local wea = worldeditadditions -- @returns number[] A list of side numbers. local function parse_sides_list(list) list = list:gsub("%s", "") -- Spaces are not permitted - return wea.table_unique(wea.table_map( + return wea.table.unique(wea.table.map( wea.split(list, ","), function(value) return tonumber(value) end )) @@ -20,7 +20,7 @@ function worldeditadditions.erode.river(heightmap_initial, heightmap, heightmap_ dolower = true -- Whether to do lower operations or not } -- Apply the custom settings - wea.table_apply(params_custom, params) + wea.table.apply(params_custom, params) params.lower_sides = parse_sides_list(params.lower_sides) params.raise_sides = parse_sides_list(params.raise_sides) diff --git a/worldeditadditions/lib/erode/snowballs.lua b/worldeditadditions/lib/erode/snowballs.lua index 10c70b3..10c7069 100644 --- a/worldeditadditions/lib/erode/snowballs.lua +++ b/worldeditadditions/lib/erode/snowballs.lua @@ -87,7 +87,7 @@ function worldeditadditions.erode.snowballs(heightmap_initial, heightmap, height count = 25000 } -- Apply the custom settings - worldeditadditions.table_apply(params_custom, params) + worldeditadditions.table.apply(params_custom, params) -- print("[erode/snowballs] params: ") -- print(worldeditadditions.format.map(params)) diff --git a/worldeditadditions/lib/noise/noise2d.lua b/worldeditadditions/lib/noise/noise2d.lua index a7efcc7..bf83a31 100644 --- a/worldeditadditions/lib/noise/noise2d.lua +++ b/worldeditadditions/lib/noise/noise2d.lua @@ -23,7 +23,7 @@ function worldeditadditions.noise2d(pos1, pos2, noise_params) manip, area, data ) - local heightmap_new = worldeditadditions.shallowcopy(heightmap_old) + local heightmap_new = worldeditadditions.table.shallowcopy(heightmap_old) local perlin_map = PerlinNoiseMap(noise_params, heightmap_size) diff --git a/worldeditadditions/lib/noise/noise_params.lua b/worldeditadditions/lib/noise/noise_params.lua index e03546d..c8539be 100644 --- a/worldeditadditions/lib/noise/noise_params.lua +++ b/worldeditadditions/lib/noise/noise_params.lua @@ -25,8 +25,8 @@ function worldeditadditions.noise.params_apply_default(params) -- If params[1] is thing, this is a list of params -- This might be a thing if we're dealingw ith multiple octaves for i,params_el in ipairs(params) do - local default_copy = worldeditadditions.shallowcopy(params_default) - worldeditadditions.table_apply( + local default_copy = worldeditadditions.table.shallowcopy(params_default) + worldeditadditions.table.apply( params_el, default_copy ) diff --git a/worldeditadditions/lib/scale_down.lua b/worldeditadditions/lib/scale_down.lua index 0c9a1c8..7cbc14f 100644 --- a/worldeditadditions/lib/scale_down.lua +++ b/worldeditadditions/lib/scale_down.lua @@ -39,7 +39,7 @@ function worldeditadditions.scale_down(pos1, pos2, scale, anchor) local manip, area = worldedit.manip_helpers.init(pos1, pos2) local data = manip:get_data() - local data_copy = worldeditadditions.shallowcopy(data) + local data_copy = worldeditadditions.table.shallowcopy(data) local node_id_air = minetest.get_content_id("air") @@ -68,7 +68,7 @@ function worldeditadditions.scale_down(pos1, pos2, scale, anchor) for x = pos2.x, pos1.x, -1 do local posi_rel = vector.subtract({ x = x, y = y, z = z }, pos1) - -- local posi_copy = worldeditadditions.shallowcopy(posi_rel) + -- local posi_copy = worldeditadditions.table.shallowcopy(posi_rel) -- posi_copy = vector.floor(vector.divide(posi_rel/*, scale_down*/)) local posi_copy = { diff --git a/worldeditadditions/lib/subdivide.lua b/worldeditadditions/lib/subdivide.lua index c5f1a9d..f026684 100644 --- a/worldeditadditions/lib/subdivide.lua +++ b/worldeditadditions/lib/subdivide.lua @@ -88,7 +88,7 @@ local function subdivide_step_afterload(state_emerge, state_ours) state_ours.times.emerge_last = wea.get_ms_time() - state_ours.times.emerge_last table.insert(state_ours.times.emerge, state_ours.times.emerge_last) if #state_ours.times.emerge > 25 then - state_ours.times.emerge = wea.table_get_last(state_ours.times.emerge, 100) + state_ours.times.emerge = wea.table.get_last(state_ours.times.emerge, 100) end state_ours.times.emerge_total = state_ours.times.emerge_total + state_ours.times.emerge_last @@ -108,7 +108,7 @@ local function subdivide_step_afterload(state_emerge, state_ours) state_ours.times.step_last = wea.get_ms_time() - state_ours.times.step_start_abs table.insert(state_ours.times.steps, state_ours.times.step_last) if #state_ours.times.steps > 25 then - state_ours.times.steps = wea.table_get_last(state_ours.times.steps, 100) + state_ours.times.steps = wea.table.get_last(state_ours.times.steps, 100) end state_ours.times.steps_total = state_ours.times.steps_total + state_ours.times.step_last state_ours.times.step_start_abs = wea.get_ms_time() diff --git a/worldeditadditions/utils/axes.lua b/worldeditadditions/utils/axes.lua index 0caab6c..dd7b3a6 100644 --- a/worldeditadditions/utils/axes.lua +++ b/worldeditadditions/utils/axes.lua @@ -36,4 +36,4 @@ function worldeditadditions.dir_to_xyz(name, dir) end -- Tests --- /lua print(unpack(worldeditadditions.player_axis2d(myname))) +-- /lua print(worldeditadditions.table.unpack(worldeditadditions.player_axis2d(myname))) diff --git a/worldeditadditions/utils/mesh.lua b/worldeditadditions/utils/mesh.lua index e496f8f..3642404 100644 --- a/worldeditadditions/utils/mesh.lua +++ b/worldeditadditions/utils/mesh.lua @@ -70,7 +70,7 @@ function Mesh.dedupe(self) for j,face_next in ipairs(self.faces) do if i ~= j -- If we're not comparing a face to itself... and face_check == face_next -- ....and the 2 faces are equal.... - and not wea.table_contains(toremove, j) then -- ...and we haven't already marked it for removal... + and not wea.table.contains(toremove, j) then -- ...and we haven't already marked it for removal... -- Mark it for removal table.insert(toremove, j) end diff --git a/worldeditadditions/utils/numbers.lua b/worldeditadditions/utils/numbers.lua index ce56a8f..6abc787 100644 --- a/worldeditadditions/utils/numbers.lua +++ b/worldeditadditions/utils/numbers.lua @@ -71,7 +71,7 @@ end function worldeditadditions.eta(existing_times, done_count, total_count) local max = 100 local average = worldeditadditions.average( - worldeditadditions.table_get_last(existing_times, max) + worldeditadditions.table.get_last(existing_times, max) ) local times_left = total_count - done_count if times_left == 0 then return 0 end diff --git a/worldeditadditions/utils/tables/init.lua b/worldeditadditions/utils/tables/init.lua index 2ccf93b..75bf05c 100644 --- a/worldeditadditions/utils/tables/init.lua +++ b/worldeditadditions/utils/tables/init.lua @@ -8,16 +8,17 @@ -- Lua doesn't exactly come with batteries included, so this is quite an -- extensive collection of functions :P --- TODO: Refactor into its own worldeditadditions.tables namespace. -worldeditadditions.tables = {} +local wea = worldeditadditions -dofile(worldeditadditions.modpath.."/utils/tables/sets.lua") -dofile(worldeditadditions.modpath.."/utils/tables/shallowcopy.lua") -dofile(worldeditadditions.modpath.."/utils/tables/table_apply.lua") -dofile(worldeditadditions.modpath.."/utils/tables/table_filter.lua") -dofile(worldeditadditions.modpath.."/utils/tables/table_get_last.lua") -dofile(worldeditadditions.modpath.."/utils/tables/table_map.lua") -dofile(worldeditadditions.modpath.."/utils/tables/table_tostring.lua") -dofile(worldeditadditions.modpath.."/utils/tables/table_unique.lua") -dofile(worldeditadditions.modpath.."/utils/tables/table_unpack.lua") -dofile(worldeditadditions.modpath.."/utils/tables/table_contains.lua") +wea.table = { + apply = dofile(wea.modpath.."/utils/tables/table_apply.lua"), + contains = dofile(wea.modpath.."/utils/tables/table_contains.lua"), + filter = dofile(wea.modpath.."/utils/tables/table_filter.lua"), + get_last = dofile(wea.modpath.."/utils/tables/table_get_last.lua"), + makeset = dofile(wea.modpath.."/utils/tables/makeset.lua"), + map = dofile(wea.modpath.."/utils/tables/table_map.lua"), + shallowcopy = dofile(wea.modpath.."/utils/tables/shallowcopy.lua"), + tostring = dofile(wea.modpath.."/utils/tables/table_tostring.lua"), + unique = dofile(wea.modpath.."/utils/tables/table_unique.lua"), + unpack = dofile(wea.modpath.."/utils/tables/table_unpack.lua"), +} diff --git a/worldeditadditions/utils/tables/sets.lua b/worldeditadditions/utils/tables/makeset.lua similarity index 52% rename from worldeditadditions/utils/tables/sets.lua rename to worldeditadditions/utils/tables/makeset.lua index 8074991..9fb5910 100644 --- a/worldeditadditions/utils/tables/sets.lua +++ b/worldeditadditions/utils/tables/makeset.lua @@ -1,9 +1,13 @@ --- Creates a table that stores data in keys. -- @source https://riptutorial.com/lua/example/13407/search-for-an-item-in-a-list -- @param list table The table of values to convert to keys. --- @return table The table of (key,true) pairs. -function worldeditadditions.makeset (list) - local set = {} - for _, l in ipairs(list) do set[l] = true end - return set +-- @return table The table of (key => true) pairs. +local function makeset(list) + local set = {} + for _, l in ipairs(list) do + set[l] = true + end + return set end + +return makeset diff --git a/worldeditadditions/utils/tables/shallowcopy.lua b/worldeditadditions/utils/tables/shallowcopy.lua index d650b25..4434749 100644 --- a/worldeditadditions/utils/tables/shallowcopy.lua +++ b/worldeditadditions/utils/tables/shallowcopy.lua @@ -3,7 +3,7 @@ -- @source http://lua-users.org/wiki/CopyTable -- @param orig table The table to clone. -- @return table The cloned table. -function worldeditadditions.shallowcopy(orig) +local function shallowcopy(orig) local orig_type = type(orig) local copy if orig_type == 'table' then @@ -16,3 +16,5 @@ function worldeditadditions.shallowcopy(orig) end return copy end + +return shallowcopy diff --git a/worldeditadditions/utils/tables/table_apply.lua b/worldeditadditions/utils/tables/table_apply.lua index 20a1f8b..779c1d2 100644 --- a/worldeditadditions/utils/tables/table_apply.lua +++ b/worldeditadditions/utils/tables/table_apply.lua @@ -2,8 +2,10 @@ -- Warning: This function mutates target! -- @param source table The source to take values from -- @param target table The target to write values to -function worldeditadditions.table_apply(source, target) +local function table_apply(source, target) for key, value in pairs(source) do target[key] = value end end + +return table_apply diff --git a/worldeditadditions/utils/tables/table_contains.lua b/worldeditadditions/utils/tables/table_contains.lua index c65fdfe..148ecb4 100644 --- a/worldeditadditions/utils/tables/table_contains.lua +++ b/worldeditadditions/utils/tables/table_contains.lua @@ -3,16 +3,11 @@ -- @param tbl table The table to look in. -- @param target any The target to look for. -- @returns bool Whether the table contains the given target or not. -local function table_contains(tbl, target) +local function contains(tbl, target) for key, value in ipairs(tbl) do if value == target then return true end end return false end - -if worldeditadditions then - worldeditadditions.table_contains = table_contains -else - return table_contains -end +return table_contains diff --git a/worldeditadditions/utils/tables/table_filter.lua b/worldeditadditions/utils/tables/table_filter.lua index 2871b11..a706904 100644 --- a/worldeditadditions/utils/tables/table_filter.lua +++ b/worldeditadditions/utils/tables/table_filter.lua @@ -7,7 +7,7 @@ -- @param tbl table The table of values to filter. -- @param func function:bool The filter function to execute - should return a boolean value indicating whether the item provided as the first argument should be kept -- @returns table A new table containing the values that the given function returned true for. -function worldeditadditions.table_filter(tbl, func) +local function table_filter(tbl, func) local result = {} for i,value in ipairs(tbl) do if func(value, i) then @@ -16,3 +16,5 @@ function worldeditadditions.table_filter(tbl, func) end return result end + +return table_filter diff --git a/worldeditadditions/utils/tables/table_get_last.lua b/worldeditadditions/utils/tables/table_get_last.lua index aaf0a49..a6ce58f 100644 --- a/worldeditadditions/utils/tables/table_get_last.lua +++ b/worldeditadditions/utils/tables/table_get_last.lua @@ -1,7 +1,17 @@ +local wea = worldeditadditions + +local table_unpack = dofile(wea.modpath.."/utils/tables/table_unpack.lua") + + --- Returns only the last count items in a given numerical table-based list. -function worldeditadditions.table_get_last(tbl, count) - return {worldeditadditions.table_unpack( +-- @param tbl table The table to fetch items from. +-- @param count number The number of items to fetch from the end of the table. +-- @returns table A table containing the last count items from the given table. +local function table_get_last(tbl, count) + return {table_unpack( tbl, math.max(0, (#tbl) - (count - 1)) )} end + +return table_get_last diff --git a/worldeditadditions/utils/tables/table_map.lua b/worldeditadditions/utils/tables/table_map.lua index 0a96616..b0f1036 100644 --- a/worldeditadditions/utils/tables/table_map.lua +++ b/worldeditadditions/utils/tables/table_map.lua @@ -3,7 +3,7 @@ -- @param tbl table The table to operate on. -- @param func function:any|nil The function to execute on every item in the table. -- @returns table A new table containing the return values of the function. -function worldeditadditions.table_map(tbl, func) +local function table_map(tbl, func) local result = {} for i,value in ipairs(tbl) do local newval = func(value, i) @@ -11,3 +11,5 @@ function worldeditadditions.table_map(tbl, func) end return result end + +return table_map diff --git a/worldeditadditions/utils/tables/table_tostring.lua b/worldeditadditions/utils/tables/table_tostring.lua index 2f73816..e6e8250 100644 --- a/worldeditadditions/utils/tables/table_tostring.lua +++ b/worldeditadditions/utils/tables/table_tostring.lua @@ -3,7 +3,7 @@ -- @param sep string key value seperator -- @param new_line string key value pair delimiter -- @return string concatenated table pairs -function worldeditadditions.table_tostring(tbl, sep, new_line) +local function table_tostring(tbl, sep, new_line) if type(sep) ~= "string" then sep = ": " end if type(new_line) ~= "string" then new_line = ", " end local ret = {} @@ -16,3 +16,5 @@ function worldeditadditions.table_tostring(tbl, sep, new_line) end return ret:concat("") end + +return table_tostring diff --git a/worldeditadditions/utils/tables/table_unique.lua b/worldeditadditions/utils/tables/table_unique.lua index 4d544c1..8dfc8ac 100644 --- a/worldeditadditions/utils/tables/table_unique.lua +++ b/worldeditadditions/utils/tables/table_unique.lua @@ -1,7 +1,7 @@ --- Builds a new table with the elements of the given table appearing at most once. -- @param tbl table The table of values to make unique. -- @returns table A new table containing the values of the given table appearing at most once. -function worldeditadditions.table_unique(tbl) +local function table_unique(tbl) local newtbl = {} for i,value in ipairs(tbl) do local seen = false @@ -17,3 +17,5 @@ function worldeditadditions.table_unique(tbl) end return newtbl end + +return table_unique diff --git a/worldeditadditions/utils/tables/table_unpack.lua b/worldeditadditions/utils/tables/table_unpack.lua index 83ceae0..9a38720 100644 --- a/worldeditadditions/utils/tables/table_unpack.lua +++ b/worldeditadditions/utils/tables/table_unpack.lua @@ -3,10 +3,12 @@ -- found. -- This is needed because in Lua 5.1 it's the global unpack(), but in Lua 5.4 -- it's moved to table.unpack(). -function worldeditadditions.table_unpack(tbl, offset, count) +local function table_unpack(tbl, offset, count) if type(unpack) == "function" then return unpack(tbl, offset, count) else return table.unpack(tbl, offset, count) end end + +return table_unpack diff --git a/worldeditadditions/utils/terrain.lua b/worldeditadditions/utils/terrain.lua index 7f9b861..3811599 100644 --- a/worldeditadditions/utils/terrain.lua +++ b/worldeditadditions/utils/terrain.lua @@ -90,7 +90,7 @@ end -- @param area VoxelArea The VoxelArea object (see worldedit.manip_helpers.init) -- @param data number[] The node ids data array containing the slice of the Minetest world extracted using the Voxel Manipulator. -- @param heightmap_old number[] The original heightmap from worldeditadditions.make_heightmap. --- @param heightmap_new number[] The new heightmap containing the altered updated values. It is expected that worldeditadditions.shallowcopy be used to make a COPY of the data worldeditadditions.make_heightmap for this purpose. Both heightmap_old AND heightmap_new are REQUIRED in order for this function to work. +-- @param heightmap_new number[] The new heightmap containing the altered updated values. It is expected that worldeditadditions.table.shallowcopy be used to make a COPY of the data worldeditadditions.make_heightmap for this purpose. Both heightmap_old AND heightmap_new are REQUIRED in order for this function to work. -- @param heightmap_size vector The x / z size of the heightmap. Any y value set in the vector is ignored. -- function worldeditadditions.apply_heightmap_changes(pos1, pos2, area, data, heightmap_old, heightmap_new, heightmap_size) diff --git a/worldeditadditions_commands/commands/ellipsoid.lua b/worldeditadditions_commands/commands/ellipsoid.lua index c08e6c7..97d3bfd 100644 --- a/worldeditadditions_commands/commands/ellipsoid.lua +++ b/worldeditadditions_commands/commands/ellipsoid.lua @@ -37,7 +37,7 @@ worldedit.register_command("ellipsoid", { require_pos = 1, parse = function(params_text) local values = {parse_params_ellipsoid(params_text)} - return unpack(values) + return wea.table.unpack(values) end, nodes_needed = function(name, target_node, radius) return math.ceil(4/3 * math.pi * radius.x * radius.y * radius.z) @@ -60,7 +60,7 @@ worldedit.register_command("hollowellipsoid", { require_pos = 1, parse = function(params_text) local values = {parse_params_ellipsoid(params_text)} - return unpack(values) + return wea.table.unpack(values) end, nodes_needed = function(name, target_node, radius) return math.ceil(4/3 * math.pi * radius.x * radius.y * radius.z) diff --git a/worldeditadditions_commands/commands/maze.lua b/worldeditadditions_commands/commands/maze.lua index 042812f..48f626d 100644 --- a/worldeditadditions_commands/commands/maze.lua +++ b/worldeditadditions_commands/commands/maze.lua @@ -95,7 +95,7 @@ worldedit.register_command("maze3d", { require_pos = 2, parse = function(params_text) local values = {parse_params_maze(params_text, true)} - return unpack(values) + return worldeditadditions.table.unpack(values) end, nodes_needed = function(name) return worldedit.volume(worldedit.pos1[name], worldedit.pos2[name]) diff --git a/worldeditadditions_commands/commands/meta/ellipsoidapply.lua b/worldeditadditions_commands/commands/meta/ellipsoidapply.lua index 652dce0..20b6bc0 100644 --- a/worldeditadditions_commands/commands/meta/ellipsoidapply.lua +++ b/worldeditadditions_commands/commands/meta/ellipsoidapply.lua @@ -51,7 +51,7 @@ worldedit.register_command("ellipsoidapply", { local success, stats_time = worldeditadditions.ellipsoidapply( worldedit.pos1[name], worldedit.pos2[name], function() - cmd.func(name, unpack(args_parsed)) + cmd.func(name, worldeditadditions.table.unpack(args_parsed)) end, args ) local time_overhead = 100 - worldeditadditions.round((stats_time.fn / stats_time.all) * 100, 3) diff --git a/worldeditadditions_commands/commands/meta/subdivide.lua b/worldeditadditions_commands/commands/meta/subdivide.lua index 00b0779..636fd9b 100644 --- a/worldeditadditions_commands/commands/meta/subdivide.lua +++ b/worldeditadditions_commands/commands/meta/subdivide.lua @@ -13,7 +13,7 @@ local function will_trigger_saferegion(name, cmd_name, args) if not parse_success then return nil, table.remove(parsed, 1) end if not def.nodes_needed then return false end - local result = def.nodes_needed(name, unpack(parsed)) + local result = def.nodes_needed(name, wea.table.unpack(parsed)) if not result then return nil, result end if result > 10000 then return true end return false @@ -117,7 +117,7 @@ worldedit.register_command("subdivide", { worldedit.pos1[name] = cpos1 worldedit.pos2[name] = cpos2 worldedit.marker_update(name) - cmd.func(name, unpack(cmd_args_parsed)) + cmd.func(name, wea.table.unpack(cmd_args_parsed)) if will_trigger_saferegion(name, cmd_name, args) then minetest.chatcommands["/y"].func(name) end diff --git a/worldeditadditions_commands/commands/selectors/smake.lua b/worldeditadditions_commands/commands/selectors/smake.lua index 5c05f2e..9ccddf9 100644 --- a/worldeditadditions_commands/commands/selectors/smake.lua +++ b/worldeditadditions_commands/commands/selectors/smake.lua @@ -18,9 +18,9 @@ worldedit.register_command("smake", { for i=3,4 do if not parts[i] then parts[i] = false end end end - -- Initialze local variables and sets - local oper, mode, targ, base = unpack(parts) - local operSet, modeSet = wea.makeset {"equal", "odd", "even"}, wea.makeset {"grow", "shrink", "avg"} + -- Initialize local variables and sets + local oper, mode, targ, base = wea.table.unpack(parts) + local operSet, modeSet = wea.table.makeset {"equal", "odd", "even"}, wea.table.makeset {"grow", "shrink", "avg"} -- Main Logic -- Check base if base is present and if so valid. diff --git a/worldeditadditions_commands/commands/torus.lua b/worldeditadditions_commands/commands/torus.lua index 973944f..6131639 100644 --- a/worldeditadditions_commands/commands/torus.lua +++ b/worldeditadditions_commands/commands/torus.lua @@ -59,7 +59,7 @@ worldedit.register_command("torus", { require_pos = 1, parse = function(params_text) local values = {parse_params_torus(params_text)} - return unpack(values) + return worldeditadditions.table.unpack(values) end, nodes_needed = function(name, target_node, major_radius, minor_radius) return math.ceil(2 * math.pi*math.pi * major_radius * minor_radius*minor_radius) @@ -88,7 +88,7 @@ worldedit.register_command("hollowtorus", { require_pos = 1, parse = function(params_text) local values = {parse_params_torus(params_text)} - return unpack(values) + return worldeditadditions.table.unpack(values) end, nodes_needed = function(name, target_node, major_radius, minor_radius) return math.ceil(2 * math.pi*math.pi * major_radius * minor_radius*minor_radius) diff --git a/worldeditadditions_commands/doc/parse_reference.lua b/worldeditadditions_commands/doc/parse_reference.lua index e774618..5784124 100644 --- a/worldeditadditions_commands/doc/parse_reference.lua +++ b/worldeditadditions_commands/doc/parse_reference.lua @@ -32,7 +32,7 @@ end function worldeditadditions.doc.parse_reference() local lines = get_reference() - local headings = worldeditadditions.table_filter( + local headings = worldeditadditions.table.filter( group_by_heading(lines, 2), function(item, i) return item.level ~= 2 end )