From cd550a7f330b2ee0b80d453779f3e66e9d749b38 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Sat, 21 Sep 2024 19:21:25 -0500 Subject: [PATCH] Fix luacheck findings for this PR: remove unused variables, remove overwritten value, add missing dependencies, fix undefined variable usage --- mods/CORE/mcl_util/nodes.lua | 1 - mods/ENTITIES/mcl_mobs/init.lua | 1 - mods/ENTITIES/mcl_mobs/mod.conf | 2 +- mods/ITEMS/mcl_bows/arrow.lua | 1 + mods/ITEMS/mcl_bows/bow.lua | 1 - mods/ITEMS/mcl_bows/crossbow.lua | 1 - mods/ITEMS/mcl_bows/rocket.lua | 36 ------------------------- mods/ITEMS/mcl_potions/lingering.lua | 2 +- mods/ITEMS/mcl_potions/splash.lua | 2 +- mods/ITEMS/mcl_potions/tipped_arrow.lua | 6 ----- mods/ITEMS/mcl_throwing/egg.lua | 1 - mods/ITEMS/mcl_throwing/ender_pearl.lua | 1 + mods/ITEMS/mcl_throwing/init.lua | 2 -- mods/ITEMS/mcl_throwing/snowball.lua | 1 - mods/ITEMS/vl_projectile/init.lua | 4 +-- mods/ITEMS/vl_projectile/mod.conf | 2 +- 16 files changed, 7 insertions(+), 57 deletions(-) diff --git a/mods/CORE/mcl_util/nodes.lua b/mods/CORE/mcl_util/nodes.lua index e7aeb2d5f..9c34fafe5 100644 --- a/mods/CORE/mcl_util/nodes.lua +++ b/mods/CORE/mcl_util/nodes.lua @@ -45,7 +45,6 @@ function mcl_util.rotate_axis_and_place(itemstack, placer, pointed_thing, infini itemstack, pointed_thing) return end - local fdir = minetest.dir_to_facedir(placer:get_look_dir()) local wield_name = itemstack:get_name() local above = pointed_thing.above diff --git a/mods/ENTITIES/mcl_mobs/init.lua b/mods/ENTITIES/mcl_mobs/init.lua index 3407f830e..28dc1c543 100644 --- a/mods/ENTITIES/mcl_mobs/init.lua +++ b/mods/ENTITIES/mcl_mobs/init.lua @@ -464,7 +464,6 @@ function mcl_mobs.register_arrow(name, def) self.object:set_velocity(dir * vel) self._puncher = puncher end, - collisionbox = def.collisionbox or {0, 0, 0, 0, 0, 0}, automatic_face_movement_dir = def.rotate and (def.rotate - (math.pi / 180)) or false, diff --git a/mods/ENTITIES/mcl_mobs/mod.conf b/mods/ENTITIES/mcl_mobs/mod.conf index 927c1c905..a3640fb4d 100644 --- a/mods/ENTITIES/mcl_mobs/mod.conf +++ b/mods/ENTITIES/mcl_mobs/mod.conf @@ -1,5 +1,5 @@ name = mcl_mobs author = PilzAdam description = Adds a mob API for mods to add animals or monsters, etc. -depends = mcl_particles, mcl_luck +depends = mcl_particles, mcl_luck, vl_projectile optional_depends = mcl_weather, mcl_explosions, mcl_hunger, mcl_worlds, invisibility, lucky_block, cmi, doc_identifier, mcl_armor, mcl_portals, mcl_experience, mcl_sculk diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index 10c88a4ff..3c478f59e 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -388,6 +388,7 @@ local arrow_entity = { if data._owner then vl_projectile_data.owner = minetest.get_player_by_name(data._owner) end + self._vl_projectile = vl_projectile_data if data.shootername then local shooter = minetest.get_player_by_name(data.shootername) diff --git a/mods/ITEMS/mcl_bows/bow.lua b/mods/ITEMS/mcl_bows/bow.lua index c295dff0e..1f61ddae4 100644 --- a/mods/ITEMS/mcl_bows/bow.lua +++ b/mods/ITEMS/mcl_bows/bow.lua @@ -1,6 +1,5 @@ local S = minetest.get_translator(minetest.get_current_modname()) -local GRAVITY = 9.81 local BOW_DURABILITY = 385 -- Charging time in microseconds diff --git a/mods/ITEMS/mcl_bows/crossbow.lua b/mods/ITEMS/mcl_bows/crossbow.lua index 404a57898..fc7d61898 100644 --- a/mods/ITEMS/mcl_bows/crossbow.lua +++ b/mods/ITEMS/mcl_bows/crossbow.lua @@ -6,7 +6,6 @@ mcl_bows_s = {} -- ["mcl_bows:arrow"] = "mcl_bows:arrow_entity", -- } -local GRAVITY = 9.81 local BOW_DURABILITY = 385 -- Charging time in microseconds diff --git a/mods/ITEMS/mcl_bows/rocket.lua b/mods/ITEMS/mcl_bows/rocket.lua index 0d431a232..c444ca53e 100644 --- a/mods/ITEMS/mcl_bows/rocket.lua +++ b/mods/ITEMS/mcl_bows/rocket.lua @@ -6,9 +6,6 @@ local vector = vector -- Time in seconds after which a stuck arrow is deleted local ROCKET_TIMEOUT = 1 --- Time after which stuck arrow is rechecked for being stuck -local STUCK_RECHECK_TIME = 0.1 - local YAW_OFFSET = -math.pi/2 local function damage_explosion(self, damagemulitplier) @@ -249,39 +246,6 @@ minetest.register_craftitem("mcl_bows:rocket", { end, }) --- Destroy arrow entity self at pos and drops it as an item -local function spawn_item(self, pos) - if not minetest.is_creative_enabled("") then - local item = minetest.add_item(pos, "mcl_bows:rocket") - item:set_velocity({x=0, y=0, z=0}) - item:set_yaw(self.object:get_yaw()) - end - mcl_burning.extinguish(self.object) - self.object:remove() -end - -local function damage_particles(pos, is_critical) - if is_critical then - minetest.add_particlespawner({ - amount = 15, - time = 0.1, - minpos = {x=pos.x-0.5, y=pos.y-0.5, z=pos.z-0.5}, - maxpos = {x=pos.x+0.5, y=pos.y+0.5, z=pos.z+0.5}, - minvel = {x=-0.1, y=-0.1, z=-0.1}, - maxvel = {x=0.1, y=0.1, z=0.1}, - minacc = {x=0, y=0, z=0}, - maxacc = {x=0, y=0, z=0}, - minexptime = 1, - maxexptime = 2, - minsize = 1.5, - maxsize = 1.5, - collisiondetection = false, - vertical = false, - texture = "mcl_particles_crit.png^[colorize:#bc7a57:127", - }) - end -end - local arrow_entity = mcl_bows.arrow_entity local rocket_entity = table.copy(arrow_entity) table.update(rocket_entity,{ diff --git a/mods/ITEMS/mcl_potions/lingering.lua b/mods/ITEMS/mcl_potions/lingering.lua index 74a98b5ef..f40380a27 100644 --- a/mods/ITEMS/mcl_potions/lingering.lua +++ b/mods/ITEMS/mcl_potions/lingering.lua @@ -213,7 +213,7 @@ function mcl_potions.register_lingering(name, descr, color, def) }, on_collide_with_entity = on_collide, on_collide_with_solid = function(self, pos, node) - if mod_target and n == "mcl_target:target_off" then + if mod_target and node.name == "mcl_target:target_off" then mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks end diff --git a/mods/ITEMS/mcl_potions/splash.lua b/mods/ITEMS/mcl_potions/splash.lua index 388d35a60..b0cb7ef3a 100644 --- a/mods/ITEMS/mcl_potions/splash.lua +++ b/mods/ITEMS/mcl_potions/splash.lua @@ -182,7 +182,7 @@ function mcl_potions.register_splash(name, descr, color, def) on_collide_with_solid = function(self, pos, node) splash_effects(self, pos, def, 4) - if node.name == "mcl_target:target_off" then + if mod_target and node.name == "mcl_target:target_off" then mcl_target.hit(pos, 0.4) -- 4 redstone ticks end end, diff --git a/mods/ITEMS/mcl_potions/tipped_arrow.lua b/mods/ITEMS/mcl_potions/tipped_arrow.lua index 356dab45c..1e610f15a 100644 --- a/mods/ITEMS/mcl_potions/tipped_arrow.lua +++ b/mods/ITEMS/mcl_potions/tipped_arrow.lua @@ -1,7 +1,5 @@ local S = minetest.get_translator(minetest.get_current_modname()) -local mod_target = minetest.get_modpath("mcl_target") - local math = math local YAW_OFFSET = -math.pi/2 @@ -15,10 +13,6 @@ end local how_to_shoot = minetest.registered_items["mcl_bows:arrow"]._doc_items_usagehelp -local mod_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements") -local mod_button = minetest.get_modpath("mesecons_button") -local enable_pvp = minetest.settings:get_bool("enable_pvp") - local arrow_longdesc = minetest.registered_items["mcl_bows:arrow"]._doc_items_longdesc or "" local arrow_tt = minetest.registered_items["mcl_bows:arrow"]._tt_help or "" diff --git a/mods/ITEMS/mcl_throwing/egg.lua b/mods/ITEMS/mcl_throwing/egg.lua index da50f4ba2..aa4adcef8 100644 --- a/mods/ITEMS/mcl_throwing/egg.lua +++ b/mods/ITEMS/mcl_throwing/egg.lua @@ -1,5 +1,4 @@ local modname = minetest.get_current_modname() -local modpath = minetest.get_modpath(modname) local S = minetest.get_translator(modname) local mod_target = minetest.get_modpath("mcl_target") diff --git a/mods/ITEMS/mcl_throwing/ender_pearl.lua b/mods/ITEMS/mcl_throwing/ender_pearl.lua index a76d48a1d..36de0fb27 100644 --- a/mods/ITEMS/mcl_throwing/ender_pearl.lua +++ b/mods/ITEMS/mcl_throwing/ender_pearl.lua @@ -65,6 +65,7 @@ vl_projectile.register("mcl_throwing:ender_pearl_entity",{ local dir = vector.zero() local v = self.object:get_velocity() + local node_def = minetest.registered_nodes[node.name] if node_def and node_def.walkable then local vc = vector.normalize(v) -- vector for calculating -- Node is walkable, we have to find a place somewhere outside of that node diff --git a/mods/ITEMS/mcl_throwing/init.lua b/mods/ITEMS/mcl_throwing/init.lua index 65958c9a1..f6497ee71 100644 --- a/mods/ITEMS/mcl_throwing/init.lua +++ b/mods/ITEMS/mcl_throwing/init.lua @@ -6,8 +6,6 @@ local modpath = minetest.get_modpath(minetest.get_current_modname()) -- Snowballs and other throwable items -- -local GRAVITY = tonumber(minetest.settings:get("movement_gravity")) - local entity_mapping = {} local velocities = {} diff --git a/mods/ITEMS/mcl_throwing/snowball.lua b/mods/ITEMS/mcl_throwing/snowball.lua index c32f9da87..a0a5a2f36 100644 --- a/mods/ITEMS/mcl_throwing/snowball.lua +++ b/mods/ITEMS/mcl_throwing/snowball.lua @@ -1,5 +1,4 @@ local modname = minetest.get_current_modname() -local modpath = minetest.get_modpath(modname) local S = minetest.get_translator(modname) local how_to_throw = S("Use the punch key to throw.") diff --git a/mods/ITEMS/vl_projectile/init.lua b/mods/ITEMS/vl_projectile/init.lua index 416f5e275..189d6af65 100644 --- a/mods/ITEMS/vl_projectile/init.lua +++ b/mods/ITEMS/vl_projectile/init.lua @@ -284,7 +284,7 @@ local function handle_entity_collision(self, entity_def, projectile_def, object) -- Light things on fire if mcl_burning.is_burning(self.object) then - mcl_burning.set_on_fire(obj, 5) + mcl_burning.set_on_fire(self.object, 5) end end @@ -320,8 +320,6 @@ end function mod.collides_with_entities(self, dtime, entity_def, projectile_def) local pos = self.object:get_pos() - local hit = nil - local objects = minetest.get_objects_inside_radius(pos, 1.5) for i = 1,#objects do local object = objects[i] diff --git a/mods/ITEMS/vl_projectile/mod.conf b/mods/ITEMS/vl_projectile/mod.conf index 5d17120b3..b59438113 100644 --- a/mods/ITEMS/vl_projectile/mod.conf +++ b/mods/ITEMS/vl_projectile/mod.conf @@ -1,3 +1,3 @@ name = vl_projectile depends = mcl_util -optional_depends = vl_physics +optional_depends = vl_physics, mcl_shields, mcl_burning