Corrige l'addition du bonus des amulettes à la connexion du joueur
This commit is contained in:
parent
5edca3189c
commit
9beb2d6830
12
amulets.lua
12
amulets.lua
@ -61,12 +61,11 @@ minetest.register_node("runes:black_magic_block", {
|
||||
})
|
||||
|
||||
-- Globalstep checking for the amulets
|
||||
tmpdata = {}
|
||||
local basemana = mana.settings.default_max -- Baseline mana, without any amulets
|
||||
loop = function()
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local inv = player:get_inventory()
|
||||
local pname = player:get_player_name()
|
||||
local basemana = mana.getmax(pname) - (tmpdata[pname] or 0) -- Baseline mana, without any amulets
|
||||
local addons = 0
|
||||
for index, item in pairs(inv:get_list("main")) do
|
||||
local itemname = item:get_name()
|
||||
@ -74,21 +73,16 @@ loop = function()
|
||||
for name, manadiff in pairs(runes.datas.amulets) do
|
||||
if itemname == "runes:" .. name .. "_amulet" then
|
||||
addons = addons + (manadiff * itemcount)
|
||||
--print("Detected " .. name)
|
||||
end
|
||||
end
|
||||
end
|
||||
mana.setmax(pname, basemana + addons)
|
||||
tmpdata[pname] = addons
|
||||
end
|
||||
minetest.after(1, loop)
|
||||
minetest.after(3, loop)
|
||||
end
|
||||
|
||||
minetest.after(0, loop)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local pname = player:get_player_name()
|
||||
mana.setmax(pname, mana.getmax(pname) - tmpdata[pname]) -- Reset
|
||||
tmpdata[pname] = nil
|
||||
mana.save_to_file(pname) -- Double class since we aren't sure mana hasn't already saved (it probably did)
|
||||
mana.setmax(player:get_player_name(), basemana)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user