From 6f9f7a2cb976e2e8d67f7bee3d85747adb875892 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 4 Dec 2020 18:46:04 +0100 Subject: [PATCH] Disable XP by default --- mods/HUD/hudbars/init.lua | 2 +- mods/HUD/mcl_experience/init.lua | 20 ++++++++++++++++++-- mods/HUD/mcl_experience/locale/template.txt | 1 + settingtypes.txt | 5 +++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/mods/HUD/hudbars/init.lua b/mods/HUD/hudbars/init.lua index 44c826656..59d8fc238 100644 --- a/mods/HUD/hudbars/init.lua +++ b/mods/HUD/hudbars/init.lua @@ -46,7 +46,7 @@ end -- Load default settings dofile(minetest.get_modpath("hudbars").."/default_settings.lua") -if minetest.get_modpath("mcl_experience") then +if minetest.get_modpath("mcl_experience") and minetest.settings:get_bool("mcl_experience", false) then -- reserve some space for experience bar: hb.settings.start_offset_left.y = hb.settings.start_offset_left.y - 20 hb.settings.start_offset_right.y = hb.settings.start_offset_right.y - 20 diff --git a/mods/HUD/mcl_experience/init.lua b/mods/HUD/mcl_experience/init.lua index 0215e6d90..68e8e6dcb 100644 --- a/mods/HUD/mcl_experience/init.lua +++ b/mods/HUD/mcl_experience/init.lua @@ -1,4 +1,5 @@ local S = minetest.get_translator("mcl_experience") +local USE_XP = minetest.settings:get_bool("mcl_experience", false) mcl_experience = {} local pool = {} local registered_nodes @@ -99,6 +100,9 @@ end -- change element of hud hud_manager.change_hud = function(data) + if not USE_XP then + return + end local name = data.player:get_player_name() if player_huds[name] and player_huds[name][data.hud_name] then data.player:hud_change(player_huds[name][data.hud_name], data.element, data.data) @@ -149,7 +153,9 @@ function mcl_experience.set_player_xp_level(player,level) end pool[name].level = level pool[name].xp, pool[name].bar_step, pool[name].next_level = mcl_experience.bar_to_xp(pool[name].bar, level) - hud_manager.change_hud({player = player, hud_name = "xp_level", element = "text", data = tostring(level)}) + if USE_XP then + hud_manager.change_hud({player = player, hud_name = "xp_level", element = "text", data = tostring(level)}) + end -- we may don't update the bar end @@ -162,6 +168,10 @@ minetest.register_on_joinplayer(function(player) name = player:get_player_name() temp_pool = pool[name] + if not USE_XP then + return + end + hud_manager.add_hud(player,"experience_bar", { hud_elem_type = "statbar", position = {x=0.5, y=1}, @@ -270,7 +280,7 @@ local name local temp_pool local xp_amount minetest.register_on_dieplayer(function(player) - if minetest.settings:get_bool("mcl_keepInventory", false) then + if minetest.settings:get_bool("mcl_keepInventory", false) or not USE_XP then return end @@ -486,6 +496,9 @@ minetest.register_chatcommand("xp", { description = S("Gives a player some XP"), privs = {server=true}, func = function(name, params) + if not USE_XP then + return false, S("XP are disabled!") + end local player, xp = nil, 1000 local P, i = {}, 0 for str in string.gmatch(params, "([^ ]+)") do @@ -517,6 +530,9 @@ minetest.register_chatcommand("xp", { }) function mcl_experience.throw_experience(pos, amount) + if not USE_XP then + return false + end local i, j = 0, 0 local obj, xp while i < amount and j < 100 do diff --git a/mods/HUD/mcl_experience/locale/template.txt b/mods/HUD/mcl_experience/locale/template.txt index 19eb6cc60..8494504e9 100644 --- a/mods/HUD/mcl_experience/locale/template.txt +++ b/mods/HUD/mcl_experience/locale/template.txt @@ -4,3 +4,4 @@ Error: Too many parameters!= Error: Incorrect value of XP= Error: Player not found= Added @1 XP to @2, total: @3, experience level: @4= +XP are disabled!= diff --git a/settingtypes.txt b/settingtypes.txt index 18471d7bf..8d67e5f91 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -86,6 +86,11 @@ mobs_disable_blood (Disable mob damage particles) bool false flame_sound (Flame sound) bool true [Experimental] +# Whether to use experience. +# Note that experience points are currently useless. + +mcl_experience (Experience) bool false + # Whether ice is translucent. If disabled, ice is fully opaque. # # Note: As of Minetest version 5.1.0, translucent ice above oceans