From 2fc3d9255038baf0711e16a38cb35d547d22a77c Mon Sep 17 00:00:00 2001 From: teknomunk Date: Tue, 28 May 2024 20:19:51 -0500 Subject: [PATCH] Convert 'strenght' to 'strength' in beacons and guard against no effect string metadata set, fix whitespace in mcl_beacons/init.lua --- mods/ITEMS/mcl_beacons/init.lua | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/mods/ITEMS/mcl_beacons/init.lua b/mods/ITEMS/mcl_beacons/init.lua index 953d036d3..f2d2916f7 100644 --- a/mods/ITEMS/mcl_beacons/init.lua +++ b/mods/ITEMS/mcl_beacons/init.lua @@ -159,7 +159,7 @@ local function remove_beacon_beam(pos) minetest.get_voxel_manip():read_from_map({x=pos.x,y=y,z=pos.z}, {x=pos.x,y=y,z=pos.z}) node = minetest.get_node({x=pos.x,y=y,z=pos.z}) end - + if node.name == "mcl_beacons:beacon_beam" then minetest.remove_node({x=pos.x,y=y,z=pos.z}) end @@ -212,24 +212,29 @@ local function effect_player(effect,pos,power_level, effect_level,player) end local function apply_effects_to_all_players(pos) - local meta = minetest.get_meta(pos) + local meta = minetest.get_meta(pos) local effect_string = meta:get_string("effect") - local effect_level = meta:get_int("effect_level") + local effect_level = meta:get_int("effect_level") - local power_level = beacon_blockcheck(pos) + local power_level = beacon_blockcheck(pos) - if effect_level == 2 and power_level < 4 then --no need to run loops when beacon is in an invalid setup :P + if effect_string == "strenght" then + effect_string = "strength" + meta:set_string("effect", effect_string) + end + + if effect_string == "" or ( effect_level == 2 and power_level < 4 ) then --no need to run loops when beacon is in an invalid setup :P return end - local beacon_distance = (power_level + 1) * 10 + local beacon_distance = (power_level + 1) * 10 for _, player in pairs(minetest.get_connected_players()) do - if vector.distance(pos, player:get_pos()) <= beacon_distance then - if not clear_obstructed_beam(pos) then - effect_player(effect_string, pos, power_level, effect_level, player) - end - end + if vector.distance(pos, player:get_pos()) <= beacon_distance then + if not clear_obstructed_beam(pos) then + effect_player(effect_string, pos, power_level, effect_level, player) + end + end end end @@ -271,7 +276,7 @@ minetest.register_node("mcl_beacons:beacon", { local meta = minetest.get_meta(pos) local inv = meta:get_inventory() local input = inv:get_stack("input",1) - + if input:is_empty() then return end @@ -353,7 +358,7 @@ minetest.register_node("mcl_beacons:beacon", { awards.unlock(sender:get_player_name(),"mcl:beacon") input:take_item() inv:set_stack("input",1,input) - + local beam_palette_index = 0 remove_beacon_beam(pos) for y = pos.y +1, pos.y + 201 do @@ -362,7 +367,6 @@ minetest.register_node("mcl_beacons:beacon", { minetest.get_voxel_manip():read_from_map({x=pos.x,y=y,z=pos.z}, {x=pos.x,y=y,z=pos.z}) node = minetest.get_node({x=pos.x,y=y,z=pos.z}) end - if minetest.get_item_group(node.name, "glass") ~= 0 or minetest.get_item_group(node.name,"material_glass") ~= 0 then beam_palette_index = get_beacon_beam(node.name)