From ba631d3af7f7976364c0ae66b468d80196081939 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Wed, 1 Jan 2025 12:15:50 -0600 Subject: [PATCH] Remove overtime warning (will be introduced as part of https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4716), update type annotations, resolve warnings --- .luarc.json | 2 ++ mods/ITEMS/mcl_lightning_rods/api.lua | 4 ++-- mods/ITEMS/mcl_lightning_rods/init.lua | 17 ++++++++++------- mods/PLAYER/mcl_player/init.lua | 5 ----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.luarc.json b/.luarc.json index 7e9e92042..1a48735b7 100644 --- a/.luarc.json +++ b/.luarc.json @@ -3,6 +3,7 @@ "diagnostics": { "disable": ["lowercase-global"] }, "diagnostics.globals": [ "minetest", + "core", "dump", "dump2", "Raycast", @@ -18,5 +19,6 @@ "AreaStore", "vector" ], + "workspace.library": ["/usr/share/luanti/luanti-lls-definitions/library", "/usr/share/luanti/builtin"], "workspace.ignoreDir": [".luacheckrc"] } diff --git a/mods/ITEMS/mcl_lightning_rods/api.lua b/mods/ITEMS/mcl_lightning_rods/api.lua index 5b79f12f7..2164d84b3 100644 --- a/mods/ITEMS/mcl_lightning_rods/api.lua +++ b/mods/ITEMS/mcl_lightning_rods/api.lua @@ -27,7 +27,7 @@ local function load_index(x,y,z) local idx_str = storage:get_string(idx_key) if idx_str and idx_str ~= "" then local idx = minetest.deserialize(idx_str) - return idx + return idx or {} end return {} @@ -156,7 +156,7 @@ function mod.index_block(pos) local idx = {} -- Setup voxel manipulator - local vm,data,area = read_voxel_area() + local _,data,area = read_voxel_area() -- Indexes to speed things up local cid_attractors = {} diff --git a/mods/ITEMS/mcl_lightning_rods/init.lua b/mods/ITEMS/mcl_lightning_rods/init.lua index 97f0ae90f..bba203186 100644 --- a/mods/ITEMS/mcl_lightning_rods/init.lua +++ b/mods/ITEMS/mcl_lightning_rods/init.lua @@ -5,9 +5,12 @@ local S = minetest.get_translator("mcl_lightning_rods") mcl_lightning_rods = {} local mod = mcl_lightning_rods +---@class core.NodeDef +---@field _on_lightning_strike? fun(pos : vector.Vector, node : core.Node) + dofile(modpath.."/api.lua") ----@type nodebox +---@type core.NodeBox local cbox = { type = "fixed", fixed = { @@ -16,7 +19,7 @@ local cbox = { }, } ----@type node_definition +---@type core.NodeDef local rod_def = { description = S("Lightning Rod"), _doc_items_longdesc = S("A block that attracts lightning"), @@ -66,10 +69,10 @@ local rod_def = { return minetest.item_place(itemstack, placer, pointed_thing, param2) end, - after_place_node = function(pos, placer, itemstack, pointed_thing) + after_place_node = function(pos) mod.register_lightning_attractor(pos) end, - after_destruct = function(pos, oldnode) + after_destruct = function(pos) mod.unregister_lightning_attractor(pos) end, _on_lightning_strike = function(pos, node) @@ -97,7 +100,7 @@ rod_def_a.mesecons = { }, } -rod_def_a.on_timer = function(pos, elapsed) +rod_def_a.on_timer = function(pos) local node = minetest.get_node(pos) if node.name == "mcl_lightning_rods:rod_powered" then --has not been dug @@ -110,7 +113,7 @@ end minetest.register_node("mcl_lightning_rods:rod_powered", rod_def_a) -lightning.register_on_strike(function(pos, pos2, objects) +lightning.register_on_strike(function(pos) local lr = mod.find_closest_attractor(pos, 64) if not lr then return end @@ -138,7 +141,7 @@ minetest.register_craft({ minetest.register_lbm({ name = "mcl_lightning_rods:index_rods", nodenames = {"mcl_lightning_rods:rod","mcl_lightning_rods:rod_powered"}, - action = function(pos, node) + action = function(pos) mod.register_lightning_attractor(pos) end }) diff --git a/mods/PLAYER/mcl_player/init.lua b/mods/PLAYER/mcl_player/init.lua index bbb0a8397..c31e8e5c9 100644 --- a/mods/PLAYER/mcl_player/init.lua +++ b/mods/PLAYER/mcl_player/init.lua @@ -214,11 +214,6 @@ local player_attached = mcl_player.player_attached -- Check each player and apply animations minetest.register_globalstep(function(dtime) - -- Track server lag greater than 110ms - if dtime > 0.11 then - minetest.log("warning", "Timestep greater than 110ms("..tostring(math.floor(dtime*1000)).." ms), server lag detected") - end - for _, player in pairs(minetest.get_connected_players()) do local name = player:get_player_name() local model_name = player_model[name]