Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
85ce5a90aa | |||
6ab62576d1 | |||
|
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)
|
||||
|
13
api.lua
13
api.lua
@ -220,13 +220,14 @@ unified_inventory.register_button("runes", {
|
||||
show_with = false, --Modif MFF (Crabman 30/06/2015)
|
||||
})
|
||||
unified_inventory.register_page("runes", {
|
||||
get_formspec = function(player)
|
||||
get_formspec = function(player, perplayer_formspec)
|
||||
local name = player:get_player_name()
|
||||
local formspec = "background[0,0.2;8,4;runes_rune_inventory.png]"..
|
||||
"background[0,4.5;8,4;ui_main_inventory.png]"..
|
||||
"size[8,10]"..
|
||||
"list[detached:"..name.."_runes;runes;0,0.2;8,4;]"
|
||||
return {formspec=formspec}
|
||||
local formspec = {
|
||||
perplayer_formspec.standard_inv_bg,
|
||||
unified_inventory.make_inv_img_grid(0.3,0.2, 8,4),
|
||||
"list[detached:"..name.."_runes;runes;0.43,0.33;8,4;]"
|
||||
}
|
||||
return {formspec=table.concat(formspec)}
|
||||
end,
|
||||
})
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
default
|
||||
unified_inventory
|
||||
mana
|
Loading…
Reference in New Issue
Block a user