mirror of
https://github.com/SmallJoker/upgrade_packs.git
synced 2024-08-19 21:04:11 +02:00
Do not damage on join
This commit is contained in:
parent
a3749baad0
commit
d948b64af4
@ -1,7 +1,3 @@
|
|||||||
if unified_inventory.sfinv_compat_layer then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
unified_inventory.register_button("ugpacks", {
|
unified_inventory.register_button("ugpacks", {
|
||||||
type = "image",
|
type = "image",
|
||||||
image = "heart.png",
|
image = "heart.png",
|
||||||
@ -13,7 +9,8 @@ unified_inventory.register_page("ugpacks", {
|
|||||||
local y = perplayer_formspec.formspec_y
|
local y = perplayer_formspec.formspec_y
|
||||||
|
|
||||||
return { formspec = (
|
return { formspec = (
|
||||||
"label[3,0;Upgrade Packs]" ..
|
"listcolors[#EEE;#EEE;#111]" ..
|
||||||
|
"label[3," .. (y + 0.2) .. ";Upgrade Packs]" ..
|
||||||
"list[current_player;ugpacks;3," .. (y + 1) .. ";2,2;]" ..
|
"list[current_player;ugpacks;3," .. (y + 1) .. ";2,2;]" ..
|
||||||
"listring[current_player;main]" ..
|
"listring[current_player;main]" ..
|
||||||
"listring[current_player;ugpacks]"
|
"listring[current_player;ugpacks]"
|
||||||
|
16
init.lua
16
init.lua
@ -5,7 +5,8 @@ upgrade_packs.breath_items = {}
|
|||||||
local modpath = minetest.get_modpath("upgrade_packs")
|
local modpath = minetest.get_modpath("upgrade_packs")
|
||||||
|
|
||||||
dofile(modpath .. "/api.lua")
|
dofile(modpath .. "/api.lua")
|
||||||
if minetest.get_modpath("unified_inventory") then
|
if minetest.get_modpath("unified_inventory")
|
||||||
|
and not unified_inventory.sfinv_compat_layer then
|
||||||
dofile(modpath .. "/gui_unified_inventory.lua")
|
dofile(modpath .. "/gui_unified_inventory.lua")
|
||||||
elseif minetest.get_modpath("sfinv") then
|
elseif minetest.get_modpath("sfinv") then
|
||||||
dofile(modpath .. "/gui_sfinv.lua")
|
dofile(modpath .. "/gui_sfinv.lua")
|
||||||
@ -46,7 +47,8 @@ minetest.after(0, function()
|
|||||||
upgrade_packs.breath_items = breath_items
|
upgrade_packs.breath_items = breath_items
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
-- Hacky: Set the hp_max and breath_max value first
|
||||||
|
table.insert(minetest.registered_on_joinplayers, 1, function(player)
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
inv:set_size("ugpacks", 4)
|
inv:set_size("ugpacks", 4)
|
||||||
upgrade_packs.update_player(player)
|
upgrade_packs.update_player(player)
|
||||||
@ -62,14 +64,16 @@ end)
|
|||||||
|
|
||||||
minetest.register_on_player_hpchange(function(player, hp_change, reason)
|
minetest.register_on_player_hpchange(function(player, hp_change, reason)
|
||||||
if hp_change >= 0 then
|
if hp_change >= 0 then
|
||||||
return
|
return hp_change
|
||||||
end
|
end
|
||||||
if reason == "drown" then
|
if reason == "drown" then
|
||||||
upgrade_packs.add_wear(player, "breath", 200)
|
upgrade_packs.add_wear(player, "breath", 400)
|
||||||
else
|
else
|
||||||
upgrade_packs.add_wear(player, "health", hp_change * -10)
|
upgrade_packs.add_wear(player, "health", hp_change * -25)
|
||||||
end
|
end
|
||||||
end, false)
|
|
||||||
|
return hp_change
|
||||||
|
end, true)
|
||||||
|
|
||||||
minetest.register_allow_player_inventory_action(function(player, action, inv, data)
|
minetest.register_allow_player_inventory_action(function(player, action, inv, data)
|
||||||
if data.to_list ~= "ugpacks" then
|
if data.to_list ~= "ugpacks" then
|
||||||
|
Loading…
Reference in New Issue
Block a user