1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-01-11 18:40:25 +01:00

fix typo in shield

update armor_inventory only when switch class
we can not be equipped with reserved armor another class
This commit is contained in:
crabman77 2015-11-27 00:17:33 +01:00
parent e44dd3e74b
commit a0f2f09e90
3 changed files with 15 additions and 9 deletions

View File

@ -486,6 +486,10 @@ minetest.register_on_joinplayer(function(player)
if not (name:split(":")[1] == "3d_armor" or name:split(":")[1] == "shields") then
return 0
end
if not pclasses.api.util.can_have_item(player:get_player_name(), name) then
return 0
end
if name:find("shield") then
for i=1, size do
local stack = player_inv:get_stack(listname, i)

View File

@ -32,4 +32,4 @@ for _, i in pairs({"helmet", "chestplate", "boots", "leggings"}) do
end
pclasses.api.reserve_item("warrior", "shields:shield_mithril")
pclasses.api.reserve_item("warrior", "shields:shield_mithril")
pclasses.api.reserve_item("warrior", "shields:shield_blackmithril")

View File

@ -56,6 +56,15 @@ function pclasses.api.set_player_class(pname, cname)
end
pclasses.data.players[pname] = cname
pclasses.api.get_class_by_name(cname).on_assigned(pname)
local ref = minetest.get_player_by_name(pname)
local armor_inv = minetest.get_inventory({type = "detached", name = pname .. "_armor"})
local inv = ref:get_inventory()
vacuum_inventory(pname, inv, "armor", true)
vacuum_inventory(pname, armor_inv, "armor", false) -- Don't move to the graveyard
armor:set_player_armor(ref)
armor:update_inventory(ref)
pclasses.api.vacuum_graveyard(minetest.get_player_by_name(pname))
end
return true
@ -116,7 +125,7 @@ end
-- Determination and reserved items tick --
-------------------------------------------
local function vacuum_inventory(name, inv, invname, bury)
function vacuum_inventory(name, inv, invname, bury)
local ref = minetest.get_player_by_name(name)
for i = 1, inv:get_size(invname) do
local stack = inv:get_stack(invname, i)
@ -141,15 +150,8 @@ end
local function tick()
for id, ref in ipairs(minetest.get_connected_players()) do
local name = ref:get_player_name()
local armor_inv = minetest.get_inventory({type = "detached", name = name .. "_armor"})
local inv = ref:get_inventory()
vacuum_inventory(name, inv, "main", true)
vacuum_inventory(name, inv, "armor", true)
vacuum_inventory(name, armor_inv, "armor", false) -- Don't move to the graveyard
armor:set_player_armor(ref)
armor:update_inventory(ref)
end
minetest.after(2, tick)
end