Disable XP by default

This commit is contained in:
Wuzzy 2020-12-04 18:46:04 +01:00
parent 945260fa29
commit 6f9f7a2cb9
4 changed files with 25 additions and 3 deletions

View File

@ -46,7 +46,7 @@ end
-- Load default settings -- Load default settings
dofile(minetest.get_modpath("hudbars").."/default_settings.lua") 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: -- reserve some space for experience bar:
hb.settings.start_offset_left.y = hb.settings.start_offset_left.y - 20 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 hb.settings.start_offset_right.y = hb.settings.start_offset_right.y - 20

View File

@ -1,4 +1,5 @@
local S = minetest.get_translator("mcl_experience") local S = minetest.get_translator("mcl_experience")
local USE_XP = minetest.settings:get_bool("mcl_experience", false)
mcl_experience = {} mcl_experience = {}
local pool = {} local pool = {}
local registered_nodes local registered_nodes
@ -99,6 +100,9 @@ end
-- change element of hud -- change element of hud
hud_manager.change_hud = function(data) hud_manager.change_hud = function(data)
if not USE_XP then
return
end
local name = data.player:get_player_name() local name = data.player:get_player_name()
if player_huds[name] and player_huds[name][data.hud_name] then 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) 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 end
pool[name].level = level pool[name].level = level
pool[name].xp, pool[name].bar_step, pool[name].next_level = mcl_experience.bar_to_xp(pool[name].bar, level) pool[name].xp, pool[name].bar_step, pool[name].next_level = mcl_experience.bar_to_xp(pool[name].bar, level)
if USE_XP then
hud_manager.change_hud({player = player, hud_name = "xp_level", element = "text", data = tostring(level)}) hud_manager.change_hud({player = player, hud_name = "xp_level", element = "text", data = tostring(level)})
end
-- we may don't update the bar -- we may don't update the bar
end end
@ -162,6 +168,10 @@ minetest.register_on_joinplayer(function(player)
name = player:get_player_name() name = player:get_player_name()
temp_pool = pool[name] temp_pool = pool[name]
if not USE_XP then
return
end
hud_manager.add_hud(player,"experience_bar", hud_manager.add_hud(player,"experience_bar",
{ {
hud_elem_type = "statbar", position = {x=0.5, y=1}, hud_elem_type = "statbar", position = {x=0.5, y=1},
@ -270,7 +280,7 @@ local name
local temp_pool local temp_pool
local xp_amount local xp_amount
minetest.register_on_dieplayer(function(player) 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 return
end end
@ -486,6 +496,9 @@ minetest.register_chatcommand("xp", {
description = S("Gives a player some XP"), description = S("Gives a player some XP"),
privs = {server=true}, privs = {server=true},
func = function(name, params) func = function(name, params)
if not USE_XP then
return false, S("XP are disabled!")
end
local player, xp = nil, 1000 local player, xp = nil, 1000
local P, i = {}, 0 local P, i = {}, 0
for str in string.gmatch(params, "([^ ]+)") do for str in string.gmatch(params, "([^ ]+)") do
@ -517,6 +530,9 @@ minetest.register_chatcommand("xp", {
}) })
function mcl_experience.throw_experience(pos, amount) function mcl_experience.throw_experience(pos, amount)
if not USE_XP then
return false
end
local i, j = 0, 0 local i, j = 0, 0
local obj, xp local obj, xp
while i < amount and j < 100 do while i < amount and j < 100 do

View File

@ -4,3 +4,4 @@ Error: Too many parameters!=
Error: Incorrect value of XP= Error: Incorrect value of XP=
Error: Player not found= Error: Player not found=
Added @1 XP to @2, total: @3, experience level: @4= Added @1 XP to @2, total: @3, experience level: @4=
XP are disabled!=

View File

@ -86,6 +86,11 @@ mobs_disable_blood (Disable mob damage particles) bool false
flame_sound (Flame sound) bool true flame_sound (Flame sound) bool true
[Experimental] [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. # Whether ice is translucent. If disabled, ice is fully opaque.
# #
# Note: As of Minetest version 5.1.0, translucent ice above oceans # Note: As of Minetest version 5.1.0, translucent ice above oceans