1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-13 14:00:32 +01:00

[runes] Fix amulets' bonuses not being removed

- Runes : Fix a bug that made the amulets' bonuses in maximum mana
   never disappear even after the amulet(s) had been removed
This commit is contained in:
LeMagnesium 2017-04-19 23:58:33 +02:00
parent 8c0a0a5547
commit 1191a57374
No known key found for this signature in database
GPG Key ID: A54DDB5272C51E8B

View File

@ -61,21 +61,27 @@ minetest.register_node("runes:black_magic_block", {
})
-- Globalstep checking for the amulets
minetest.register_globalstep(function(dtime)
tmpdata = {}
loop = function()
for _, player in pairs(minetest.get_connected_players()) do
local inv = player:get_inventory()
local basemana = mana.settings.default_max
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()
local itemcount = item:get_count()
for name, manadiff in pairs(runes.datas.amulets) do
if itemname == "runes:" .. name .. "_amulet" then
basemana = basemana + (manadiff * itemcount)
addons = addons + (manadiff * itemcount)
print("Detected " .. name)
end
end
end
if basemana ~= mana.settings.default_max then
mana.setmax(player:get_player_name(), basemana)
end
mana.setmax(pname, basemana + addons)
tmpdata[pname] = addons
end
end)
minetest.after(1, loop)
end
minetest.after(0, loop)