From 74e3dfa0d77c9d69af55ef61a317becc067e7b85 Mon Sep 17 00:00:00 2001 From: chmodsayshello Date: Sun, 24 Jul 2022 12:32:20 +0200 Subject: [PATCH] beacon related achievements --- mods/HUD/mcl_achievements/init.lua | 13 +++++++ .../locale/mcl_achievements.de.tr | 4 ++ mods/HUD/mcl_achievements/locale/template.txt | 4 ++ mods/ITEMS/mcl_beacons/init.lua | 37 ++++++++++--------- mods/ITEMS/mcl_beacons/mod.conf | 2 +- 5 files changed, 41 insertions(+), 19 deletions(-) diff --git a/mods/HUD/mcl_achievements/init.lua b/mods/HUD/mcl_achievements/init.lua index a70ee5b40..9e7f6811b 100644 --- a/mods/HUD/mcl_achievements/init.lua +++ b/mods/HUD/mcl_achievements/init.lua @@ -272,6 +272,19 @@ awards.register_achievement("mcl:enchanter", { icon = "mcl_enchanting_book_enchanted.png", }) +--Triggered in mcl_beacons +awards.register_achievement("mcl:beacon", { + title = S("Bring Home the Beacon"), + description = S("Use a beacon."), + icon = "beacon_side_3.png", +}) + +awards.register_achievement("mcl:maxed_beacon", { + title = S("Beaconator"), + description = S("Use a fully powered beacon."), + icon = "beacon_side_4.png", +}) + -- NON-PC ACHIEVEMENTS (XBox, Pocket Edition, etc.) if non_pc_achievements then diff --git a/mods/HUD/mcl_achievements/locale/mcl_achievements.de.tr b/mods/HUD/mcl_achievements/locale/mcl_achievements.de.tr index 49c486e48..885bf1d7e 100644 --- a/mods/HUD/mcl_achievements/locale/mcl_achievements.de.tr +++ b/mods/HUD/mcl_achievements/locale/mcl_achievements.de.tr @@ -47,3 +47,7 @@ Use a crafting table to craft a wooden hoe from wooden planks and sticks.=Benutz Use a crafting table to craft a wooden pickaxe from wooden planks and sticks.=Benutzen Sie eine Werkbank, um eine Holzspitzhacke aus Holzplanken und Stöcken zu fertigen. Use obsidian and a fire starter to construct a Nether portal.=Benutzen Sie Obsidian und ein Feuerzeug, um ein Netherportal zu errichten. Use wheat to craft a bread.=Benutzen Sie Weizen, um ein Brot zu machen. +Bring Home the Beacon=Den Nachbarn heimleuchten +Use a beacon.=Benutzen Sie ein Leuchtfeuer. +Beaconator=Leuchtturmwärter +Use a fully powered beacon.=Benutzen Sie ein vollständiges Leuchtfeuer. diff --git a/mods/HUD/mcl_achievements/locale/template.txt b/mods/HUD/mcl_achievements/locale/template.txt index 4bbe5db3e..5fcef4238 100644 --- a/mods/HUD/mcl_achievements/locale/template.txt +++ b/mods/HUD/mcl_achievements/locale/template.txt @@ -75,3 +75,7 @@ Local Brewery= Brew a Potion.@nHint: Take a potion or glass bottle out of the brewing stand.= Enchanter= Enchant an item using an Enchantment Table.= +Bring Home the Beacon= +Use a beacon.= +Beaconator= +Use a fully powered beacon.= diff --git a/mods/ITEMS/mcl_beacons/init.lua b/mods/ITEMS/mcl_beacons/init.lua index 158995e91..9262c7641 100644 --- a/mods/ITEMS/mcl_beacons/init.lua +++ b/mods/ITEMS/mcl_beacons/init.lua @@ -63,24 +63,21 @@ local function beacon_blockcheck(pos) end end -local function effect_player(effect,pos,power_level, effect_level) - local all_objects = minetest.get_objects_inside_radius(pos, ((power_level+1)*10)) - for _,obj in ipairs(all_objects) do - if obj:is_player() then - if effect == "swiftness" then - mcl_potions.swiftness_func(obj,effect_level,16) - elseif effect == "leaping" then - mcl_potions.leaping_func(obj, effect_level, 16) - elseif effect == "strenght" then - mcl_potions.strength_func(obj, effect_level, 16) - elseif effect == "regeneration" then - mcl_potions.regeneration_func(obj, effect_level, 16) - end - end +local function effect_player(effect,pos,power_level, effect_level,player) + local distance = vector.distance(player:get_pos(), pos) + if distance > (power_level+1)*10 then return end + if effect == "swiftness" then + mcl_potions.swiftness_func(player,effect_level,16) + elseif effect == "leaping" then + mcl_potions.leaping_func(player, effect_level, 16) + elseif effect == "strenght" then + mcl_potions.strength_func(player, effect_level, 16) + elseif effect == "regeneration" then + mcl_potions.regeneration_func(player, effect_level, 16) end end -local function globalstep_function(pos) +local function globalstep_function(pos,player) local meta = minetest.get_meta(pos) local power_level = beacon_blockcheck(pos) local effect_string = meta:get_string("effect") @@ -97,7 +94,7 @@ local function globalstep_function(pos) end end if obstructed then return end - effect_player(effect_string,pos,power_level,meta:get_int("effect_level")) + effect_player(effect_string,pos,power_level,meta:get_int("effect_level"),player) end end @@ -181,9 +178,13 @@ minetest.register_node("mcl_beacons:beacon", { successful = true end if successful then + if power_level == 4 then + awards.unlock(sender:get_player_name(),"mcl:maxed_beacon") + end + awards.unlock(sender:get_player_name(),"mcl:beacon") input:take_item() inv:set_stack("input",1,input) - globalstep_function(pos)--call it once outside the globalstep so the player gets the effect right after selecting it + globalstep_function(pos,sender)--call it once outside the globalstep so the player gets the effect right after selecting it end end end, @@ -214,7 +215,7 @@ minetest.register_globalstep(function(dtime) local player_pos = player.get_pos(player) local pos_list = minetest.find_nodes_in_area({x=player_pos.x-50, y=player_pos.y-50, z=player_pos.z-50}, {x=player_pos.x+50, y=player_pos.y+50, z=player_pos.z+50},"mcl_beacons:beacon") for _, pos in ipairs(pos_list) do - globalstep_function(pos) + globalstep_function(pos,player) end end timer = 0 diff --git a/mods/ITEMS/mcl_beacons/mod.conf b/mods/ITEMS/mcl_beacons/mod.conf index 98bd645ee..edb641946 100644 --- a/mods/ITEMS/mcl_beacons/mod.conf +++ b/mods/ITEMS/mcl_beacons/mod.conf @@ -1,2 +1,2 @@ author=chmodsayshello -depends=mcl_formspec, mcl_init, mcl_wip, mesecons_mvps, mcl_core, mcl_sounds +depends=mcl_formspec, mcl_init, mcl_wip, mesecons_mvps, mcl_core, mcl_sounds, awards, mcl_achievements