Fix some luacheck errors

the others are because rotate.lua isn't finished
Unfortunately I don't have the time to fix it now, because it will require a lot of time
This commit is contained in:
Starbeamrainbowlabs 2024-10-02 01:17:41 +01:00
parent e8dca3ce7d
commit d74427e017
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2
7 changed files with 18 additions and 17 deletions

@ -21,7 +21,7 @@ globals = {
"worldedit",
"worldeditadditions",
"worldeditadditions_commands",
"worldeditadditions_core"
"worldeditadditions_core",
}
-- Read-only globals
read_globals = {
@ -35,6 +35,7 @@ read_globals = {
"dofile",
"PerlinNoise",
"Settings",
"VoxelArea"
"VoxelArea",
"pova" -- optional mod support
}
std = "max"

@ -145,7 +145,7 @@ end
-- TEST example code, TODO test this
function test()
local function test()
return Promise.new(function(resolve, reject)
-- TODO do something asyncy here
print("DEBUG running test function")

@ -22,7 +22,7 @@ core.register_command("set+", {
local parts = core.split_shell(params_text)
local mode = "param"
local value = nil
local value -- defaults to nil
local possible_modes = { "param", "p", "param2", "p2", "light", "l" }

@ -17,7 +17,7 @@ local wallmounted_cycles = {
}
-- We have standardised on radians for other rotation operations, so it wouldn't make sense for the API-facing functions in this file to use a number of times or degrees, as this would be inconsistent
function convert_normalise_rad(rad)
local function convert_normalise_rad(rad)
local deg = math.deg(rad)
local times = worldeditadditions_core.round(deg / 90)
return math.floor(times) -- ensure it's an integer and not e.g. a float 1.0
@ -35,16 +35,16 @@ end
-- @param axis string The name of the axis to rotate around. Valid values: `x`, `y`, `z`
-- @param amount The number of radians to rotate around the given `axis`. Only right angles are supported (i.e. 90° increments). Any value that isn't a 90° increment will be **rounded**!
-- @returns number A new param2 value that is rotated the given number of degrees around the given `axis`
function facedir(param2, axis, amount_rad)
local function facedir(param2, axis, amount_rad)
local amount = convert_normalise_rad(amount_rad)
print("DEBUG:core/orientation:facedir AMOUNT rad "..tostring(amount_rad).." norm "..tostring(amount))
local facedir = param2 % 32
local facedir_this = param2 % 32
for _, cycle in ipairs(facedir_cycles[axis]) do
-- Find the current facedir
-- Minetest adds table.indexof, but I refuse to use it because it returns -1 rather than nil
for i, fd in ipairs(cycle) do
if fd == facedir then
return param2 - facedir + cycle[1 + (i - 1 + amount) % 4] -- If only Lua didn't use 1 indexing...
if fd == facedir_this then
return param2 - facedir_this + cycle[1 + (i - 1 + amount) % 4] -- If only Lua didn't use 1 indexing...
end
end
end
@ -56,14 +56,14 @@ end
-- @param axis string The name of the axis to rotate around. Valid values: `x`, `y`, `z`
-- @param amount The number of radians to rotate around the given `axis`. Only right angles are supported (i.e. 90° increments). Any value that isn't a 90° increment will be **rounded**!
-- @returns number A new param2 value that is rotated the given number of degrees around the given `axis`
function wallmounted(param2, axis, amount_rad)
local function wallmounted(param2, axis, amount_rad)
local amount = convert_normalise_rad(amount_rad)
print("DEBUG:core/orientation:wallmounted AMOUNT rad " .. tostring(amount_rad) .. " norm " .. tostring(amount))
local wallmounted = param2 % 8
local wallmounted_this = param2 % 8
for i, wm in ipairs(wallmounted_cycles[axis]) do
if wm == wallmounted then
return param2 - wallmounted + wallmounted_cycles[axis][1 + (i - 1 + amount) % 4]
if wm == wallmounted_this then
return param2 - wallmounted_this + wallmounted_cycles[axis][1 + (i - 1 + amount) % 4]
end
end
return param2

@ -15,7 +15,7 @@ local function calc_rotation_text(rotation)
end
end
function rot_axis_left(axis)
local function rot_axis_left(axis)
if axis.x == 1 or axis.x == -1 then
axis.x, axis.z = 0, axis.x
elseif axis.z == 1 or axis.z == -1 then

@ -12,7 +12,7 @@
-- 2. `i` (number): The index in the table that the value can be found at
-- 3. `tbl` (table): The original table.
-- @return any|nil The first element in the table that satisfies the predicate, or nil if no such element is found.
function find(tbl, func)
local function find(tbl, func)
for i,value in ipairs(tbl) do
if func(value, i, tbl) then
return value

@ -3,7 +3,7 @@
--- Returns the key value pairs in a table as a single string
-- @param tbl table input table
-- @param sep string key value seperator
-- @param sep string key value separator
-- @param new_line string key value pair delimiter
-- @param max_depth number max recursion depth (optional)
-- @return string concatenated table pairs
@ -17,7 +17,7 @@ local function tostring(tbl, sep, new_line, max_depth)
for key,value in pairs(tbl) do
if type(value) == "table" and max_depth.depth < max_depth.max then
table.insert(ret,tostring(key) .. sep ..
"{" .. table_tostring(value,sep,new_line,{max_depth.depth+1,max_depth.max}) .. "}")
"{" .. tostring(value,sep,new_line,{max_depth.depth+1,max_depth.max}) .. "}")
else
table.insert(ret,tostring(key) .. sep .. tostring(value))
end