Add gamerule keepInventory and migrate existing setting value from mcl_keepInvetory

This commit is contained in:
teknomunk 2024-06-09 21:29:01 -05:00
parent 75565e7118
commit f819b31613
11 changed files with 25 additions and 15 deletions

View file

@ -1,4 +1,5 @@
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local S = minetest.get_translator(modname)
local storage = minetest.get_mod_storage()
local mod = {}
@ -57,6 +58,8 @@ function mod.setting(setting, setting_type, def )
-- return the existing setting if it was previously registered. Don't update the definition
local tunable = tunables[setting]
if tunable then return tunable end
assert(setting_type)
assert(def)
-- Setup the tunable data
tunable = table.copy(def)
@ -149,3 +152,4 @@ minetest.register_chatcommand("gamerule", {
end
})
dofile(modpath.."/settings.lua")

View file

@ -237,8 +237,9 @@ minetest.register_on_leaveplayer(function(player)
caches[player] = nil
end)
local keep_inventory = vl_tuning.setting("gamerule:keepInventory")
minetest.register_on_dieplayer(function(player)
if not minetest.settings:get_bool("mcl_keepInventory", false) then
if not keep_inventory[1] then
mcl_experience.throw_xp(player:get_pos(), mcl_experience.get_xp(player))
mcl_experience.set_xp(player, 0)
end

View file

@ -1,4 +1,4 @@
name = mcl_experience
author = oilboi
description = eXPerience mod
depends = mcl_gamemode, mcl_luck
depends = mcl_gamemode, mcl_luck, vl_tuning

View file

@ -1,3 +1,3 @@
name = mcl_farming
depends = mcl_core, mcl_sounds, mcl_wool, mcl_torches, mcl_weather, mobs_mc, mcl_colors, mcl_init
depends = mcl_core, mcl_sounds, mcl_wool, mcl_torches, mcl_weather, mobs_mc, mcl_colors, mcl_init, vl_tuning
optional_depends = mcl_armor, doc

View file

@ -175,8 +175,9 @@ if minetest.get_modpath("mcl_armor") then
add_pumpkin_hud(player)
end
end)
local keep_inventory = vl_tuning.setting("gamerule:keepInventory")
minetest.register_on_dieplayer(function(player)
if not minetest.settings:get_bool("mcl_keepInventory") then
if not keep_inventory[1] then
remove_pumpkin_hud(player)
end
end)

View file

@ -434,9 +434,10 @@ minetest.register_globalstep(function(dtime)
end
end)
local keep_inventory = vl_tuning.setting("gamerule:keepInventory")
minetest.register_on_dieplayer(function(player)
remove_shield_hud(player)
if not minetest.settings:get_bool("mcl_keepInventory") then
if not keep_inventory[1] then
remove_shield_entity(player, 1)
remove_shield_entity(player, 2)
end

View file

@ -1,3 +1,3 @@
name = mcl_shields
author = NO11
depends = mcl_damage, mcl_enchanting, mcl_banners, mcl_util, playerphysics
depends = mcl_damage, mcl_enchanting, mcl_banners, mcl_util, playerphysics, vl_tuning

View file

@ -6,6 +6,8 @@ mcl_death_drop = {}
mcl_death_drop.registered_dropped_lists = {}
local keep_inventory = vl_tuning.setting("gamerule:keepInventory")
function mcl_death_drop.register_dropped_list(inv, listname, drop)
table.insert(mcl_death_drop.registered_dropped_lists, {inv = inv, listname = listname, drop = drop})
end
@ -16,8 +18,7 @@ mcl_death_drop.register_dropped_list("PLAYER", "armor", true)
mcl_death_drop.register_dropped_list("PLAYER", "offhand", true)
minetest.register_on_dieplayer(function(player)
local keep = minetest.settings:get_bool("mcl_keepInventory", false)
if keep == false then
if not keep_inventory[1] then
-- Drop inventory, crafting grid and armor
local playerinv = player:get_inventory()
local pos = player:get_pos()

View file

@ -1,4 +1,4 @@
name = mcl_death_drop
author = Wuzzy
description = Makes all items in inventory drop after player death.
depends = mcl_armor, mcl_enchanting
depends = mcl_armor, mcl_enchanting, vl_tuning

View file

@ -735,8 +735,10 @@ end
init()
if not minetest.settings:get_bool("mcl_keepInventory", false) then
local keep_inventory = vl_tuning.setting("gamerule:keepInventory")
minetest.register_on_respawnplayer(function(player)
if not keep_inventory[1] then
mcl_skins.update_player_skin(player) -- ensures players have their cape again after dying with an elytra
end)
end
end)

View file

@ -1,4 +1,4 @@
name = mcl_skins
author = MrRar
description = Advanced player skin customization.
depends = mcl_player
depends = mcl_player, vl_tuning