mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2024-11-18 00:18:13 +01:00
Remove ignore list and fix many warnings
This commit is contained in:
parent
198cd4b4bc
commit
25aaab20de
10
.luacheckrc
10
.luacheckrc
@ -2,16 +2,6 @@ unused_args = false
|
||||
allow_defined_top = true
|
||||
max_line_length = 999
|
||||
|
||||
ignore = {
|
||||
"pos1", "pos2",
|
||||
"extent1", "extent2",
|
||||
"header", "count",
|
||||
|
||||
"err", "state",
|
||||
"filename", "def",
|
||||
"file", "name",
|
||||
}
|
||||
|
||||
read_globals = {
|
||||
string = {fields = {"split", "trim"}},
|
||||
table = {fields = {"copy", "getn"}},
|
||||
|
@ -8,7 +8,8 @@ function worldedit.lua(code)
|
||||
if not func then -- Syntax error
|
||||
return err
|
||||
end
|
||||
local good, err = pcall(func)
|
||||
local good = pcall(func)
|
||||
err = pcall(func)
|
||||
if not good then -- Runtime error
|
||||
return err
|
||||
end
|
||||
@ -37,7 +38,8 @@ function worldedit.luatransform(pos1, pos2, code)
|
||||
while pos.y <= pos2.y do
|
||||
pos.z = pos1.z
|
||||
while pos.z <= pos2.z do
|
||||
local good, err = pcall(func, pos)
|
||||
local good = pcall(func)
|
||||
err = pcall(func, pos)
|
||||
if not good then -- Runtime error
|
||||
return err
|
||||
end
|
||||
|
@ -23,7 +23,7 @@ end
|
||||
--- Determines the volume of the region defined by positions `pos1` and `pos2`.
|
||||
-- @return The volume.
|
||||
function worldedit.volume(pos1, pos2)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
return (pos2.x - pos1.x + 1) *
|
||||
(pos2.y - pos1.y + 1) *
|
||||
(pos2.z - pos1.z + 1)
|
||||
|
@ -26,8 +26,13 @@ end
|
||||
|
||||
function worldedit.metaload(originpos, filename)
|
||||
deprecated("load")
|
||||
|
||||
local file = io.open(filename, "wb")
|
||||
filename = minetest.get_worldpath() .. "/schems/" .. file .. ".wem"
|
||||
local file, err = io.open(filename, "wb")
|
||||
file = io.open(filename, "wb")
|
||||
|
||||
local err = io.open(filename, "wb")
|
||||
|
||||
if err then return 0 end
|
||||
local data = file:read("*a")
|
||||
return worldedit.deserialize(originpos, data)
|
||||
|
@ -66,7 +66,7 @@ end
|
||||
-- When `inverse` is `true`, replaces all instances that are NOT `search_node`.
|
||||
-- @return The number of nodes replaced.
|
||||
function worldedit.replace(pos1, pos2, search_node, replace_node, inverse)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
local manip, area = mh.init(pos1, pos2)
|
||||
local data = manip:get_data()
|
||||
@ -150,7 +150,7 @@ end
|
||||
-- @param amount
|
||||
-- @return The number of nodes copied.
|
||||
function worldedit.copy(pos1, pos2, axis, amount)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
-- Decide if we need to copy stuff backwards (only applies to metadata)
|
||||
local backwards = amount > 0 and amount < (pos2[axis] - pos1[axis] + 1)
|
||||
@ -167,7 +167,7 @@ end
|
||||
-- @param meta_backwards (not officially part of API)
|
||||
-- @return The number of nodes copied.
|
||||
function worldedit.copy2(pos1, pos2, off, meta_backwards)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
local src_manip, src_area = mh.init(pos1, pos2)
|
||||
local src_stride = {x=1, y=src_area.ystride, z=src_area.zstride}
|
||||
@ -252,7 +252,7 @@ end
|
||||
-- @param pos2
|
||||
-- @return The number of nodes that had their meta deleted.
|
||||
function worldedit.delete_meta(pos1, pos2)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
local meta_positions = minetest.find_nodes_with_meta(pos1, pos2)
|
||||
local get_meta = minetest.get_meta
|
||||
@ -266,7 +266,7 @@ end
|
||||
--- Moves a region along `axis` by `amount` nodes.
|
||||
-- @return The number of nodes moved.
|
||||
function worldedit.move(pos1, pos2, axis, amount)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
local dim = vector.add(vector.subtract(pos2, pos1), 1)
|
||||
local overlap = math.abs(amount) < dim[axis]
|
||||
@ -315,7 +315,7 @@ end
|
||||
-- @param count
|
||||
-- @return The number of nodes stacked.
|
||||
function worldedit.stack(pos1, pos2, axis, count, finished)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
local length = pos2[axis] - pos1[axis] + 1
|
||||
if count < 0 then
|
||||
count = -count
|
||||
@ -346,7 +346,7 @@ end
|
||||
-- @return The new scaled position 1.
|
||||
-- @return The new scaled position 2.
|
||||
function worldedit.stretch(pos1, pos2, stretch_x, stretch_y, stretch_z)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
-- Prepare schematic of large node
|
||||
local get_node, get_meta, place_schematic = minetest.get_node,
|
||||
@ -418,18 +418,18 @@ end
|
||||
-- @return The new transposed position 1.
|
||||
-- @return The new transposed position 2.
|
||||
function worldedit.transpose(pos1, pos2, axis1, axis2)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
local compare
|
||||
local extent1, extent2 = pos2[axis1] - pos1[axis1], pos2[axis2] - pos1[axis2]
|
||||
|
||||
if extent1 > extent2 then
|
||||
compare = function(extent1, extent2)
|
||||
return extent1 > extent2
|
||||
compare = function(extent1_2, extent2_2)
|
||||
return extent1_2 > extent2_2
|
||||
end
|
||||
else
|
||||
compare = function(extent1, extent2)
|
||||
return extent1 < extent2
|
||||
compare = function(extent1_2, extent2_2)
|
||||
return extent1_2 < extent2_2
|
||||
end
|
||||
end
|
||||
|
||||
@ -451,7 +451,7 @@ function worldedit.transpose(pos1, pos2, axis1, axis2)
|
||||
while pos.y <= pos2.y do
|
||||
pos.z = pos1.z
|
||||
while pos.z <= pos2.z do
|
||||
local extent1, extent2 = pos[axis1] - pos1[axis1], pos[axis2] - pos1[axis2]
|
||||
extent1, extent2 = pos[axis1] - pos1[axis1], pos[axis2] - pos1[axis2]
|
||||
if compare(extent1, extent2) then -- Transpose only if below the diagonal
|
||||
local node1 = get_node(pos)
|
||||
local meta1 = get_meta(pos):to_table()
|
||||
@ -478,7 +478,7 @@ end
|
||||
--- Flips a region along `axis`.
|
||||
-- @return The number of nodes flipped.
|
||||
function worldedit.flip(pos1, pos2, axis)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
@ -523,7 +523,7 @@ end
|
||||
-- @return The new first position.
|
||||
-- @return The new second position.
|
||||
function worldedit.rotate(pos1, pos2, axis, angle)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
local other1, other2 = worldedit.get_axis_others(axis)
|
||||
angle = angle % 360
|
||||
@ -551,7 +551,7 @@ end
|
||||
-- @param angle Angle in degrees (90 degree increments only).
|
||||
-- @return The number of nodes oriented.
|
||||
function worldedit.orient(pos1, pos2, angle)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
local registered_nodes = minetest.registered_nodes
|
||||
|
||||
local wallmounted = {
|
||||
@ -621,7 +621,7 @@ end
|
||||
--- Attempts to fix the lighting in a region.
|
||||
-- @return The number of nodes updated.
|
||||
function worldedit.fixlight(pos1, pos2)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
local vmanip = minetest.get_voxel_manip(pos1, pos2)
|
||||
vmanip:write_to_map()
|
||||
|
@ -148,7 +148,7 @@ end
|
||||
--- Loads the schematic in `value` into a node list in the latest format.
|
||||
-- @return A node list in the latest format, or nil on failure.
|
||||
local function load_schematic(value)
|
||||
local version, header, content = worldedit.read_header(value)
|
||||
local version, _, content = worldedit.read_header(value)
|
||||
local nodes = {}
|
||||
if version == 1 or version == 2 then -- Original flat table format
|
||||
local tables = minetest.deserialize(content, true)
|
||||
@ -240,7 +240,6 @@ function worldedit.deserialize(origin_pos, value)
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local origin_x, origin_y, origin_z = origin_pos.x, origin_pos.y, origin_pos.z
|
||||
local count = 0
|
||||
local add_node, get_meta = minetest.add_node, minetest.get_meta
|
||||
for i, entry in ipairs(nodes) do
|
||||
entry.x, entry.y, entry.z = origin_x + entry.x, origin_y + entry.y, origin_z + entry.z
|
||||
|
@ -111,7 +111,7 @@ end
|
||||
-- by positions `pos1` and `pos2`.
|
||||
-- @return The number of nodes restored.
|
||||
function worldedit.restore(pos1, pos2)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
|
@ -43,7 +43,7 @@ local brush_on_use = function(itemstack, placer)
|
||||
|
||||
-- this isn't really clean...
|
||||
local player_notify_old = worldedit.player_notify
|
||||
worldedit.player_notify = function(name, msg)
|
||||
worldedit.player_notify = function(player, msg)
|
||||
if string.match(msg, "^%d") then return end -- discard "1234 nodes added."
|
||||
return player_notify_old(name, msg)
|
||||
end
|
||||
|
@ -82,7 +82,7 @@ end
|
||||
-- end,
|
||||
-- }
|
||||
function worldedit.register_command(name, def)
|
||||
local def = table.copy(def)
|
||||
def = table.copy(def)
|
||||
assert(name and #name > 0)
|
||||
assert(def.privs)
|
||||
def.require_pos = def.require_pos or 0
|
||||
@ -1030,7 +1030,8 @@ worldedit.register_command("stretch", {
|
||||
end,
|
||||
func = function(name, stretchx, stretchy, stretchz)
|
||||
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
|
||||
local count, pos1, pos2 = worldedit.stretch(pos1, pos2, stretchx, stretchy, stretchz)
|
||||
local count = worldedit.stretch(pos1, pos2, stretchx, stretchy, stretchz)
|
||||
pos1, pos2 = worldedit.stretch(pos1, pos2, stretchx, stretchy, stretchz)
|
||||
|
||||
--reset markers to scaled positions
|
||||
worldedit.pos1[name] = pos1
|
||||
@ -1061,7 +1062,9 @@ worldedit.register_command("transpose", {
|
||||
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
|
||||
if axis1 == "?" then axis1 = worldedit.player_axis(name) end
|
||||
if axis2 == "?" then axis2 = worldedit.player_axis(name) end
|
||||
local count, pos1, pos2 = worldedit.transpose(pos1, pos2, axis1, axis2)
|
||||
|
||||
local count = worldedit.transpose(pos1, pos2, axis1, axis2)
|
||||
pos1, pos2 = worldedit.transpose(pos1, pos2, axis1, axis2)
|
||||
|
||||
--reset markers to transposed positions
|
||||
worldedit.pos1[name] = pos1
|
||||
@ -1112,7 +1115,9 @@ worldedit.register_command("rotate", {
|
||||
func = function(name, axis, angle)
|
||||
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
|
||||
if axis == "?" then axis = worldedit.player_axis(name) end
|
||||
local count, pos1, pos2 = worldedit.rotate(pos1, pos2, axis, angle)
|
||||
|
||||
local count = worldedit.rotate(pos1, pos2, axis, angle)
|
||||
pos1, pos2 = worldedit.rotate(pos1, pos2, axis, angle)
|
||||
|
||||
--reset markers to rotated positions
|
||||
worldedit.pos1[name] = pos1
|
||||
@ -1248,7 +1253,7 @@ worldedit.register_command("restore", {
|
||||
})
|
||||
|
||||
local function detect_misaligned_schematic(name, pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
pos1 = worldedit.sort_pos(pos1, pos2)
|
||||
-- Check that allocate/save can position the schematic correctly
|
||||
-- The expected behaviour is that the (0,0,0) corner of the schematic stays
|
||||
-- sat pos1, this only works when the minimum position is actually present
|
||||
|
@ -4,7 +4,7 @@ worldedit.marker_region = {}
|
||||
|
||||
--marks worldedit region position 1
|
||||
worldedit.mark_pos1 = function(name)
|
||||
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
|
||||
local pos1 = worldedit.pos1[name]
|
||||
|
||||
if pos1 ~= nil then
|
||||
--make area stay loaded
|
||||
@ -27,7 +27,7 @@ end
|
||||
|
||||
--marks worldedit region position 2
|
||||
worldedit.mark_pos2 = function(name)
|
||||
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
|
||||
local pos2 = worldedit.pos2[name]
|
||||
|
||||
if pos2 ~= nil then
|
||||
--make area stay loaded
|
||||
@ -60,7 +60,7 @@ worldedit.mark_region = function(name)
|
||||
end
|
||||
|
||||
if pos1 ~= nil and pos2 ~= nil then
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
local vec = vector.subtract(pos2, pos1)
|
||||
local maxside = math.max(vec.x, math.max(vec.y, vec.z))
|
||||
|
Loading…
Reference in New Issue
Block a user