mirror of
https://github.com/SmallJoker/upgrade_packs.git
synced 2025-01-02 19:17:39 +01:00
Add sfinv & no inventory support, remove print
This commit is contained in:
parent
c9015954fc
commit
a3749baad0
12
gui_plain.lua
Normal file
12
gui_plain.lua
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
minetest.register_chatcommand("upgrade_packs", {
|
||||||
|
description = "Allows inserting upgrade packs without CSM",
|
||||||
|
func = function(name, param)
|
||||||
|
minetest.show_formspec(name, "upgrade_packs:gui_plain",
|
||||||
|
"size[8,7]" ..
|
||||||
|
"label[3,0;Upgrade Packs]" ..
|
||||||
|
"list[current_player;ugpacks;2,1;4,1;]" ..
|
||||||
|
"list[current_player;main;0,3;8,4;]" ..
|
||||||
|
"listring[]"
|
||||||
|
)
|
||||||
|
end
|
||||||
|
})
|
@ -1,2 +1,12 @@
|
|||||||
-- TODO
|
sfinv.register_page("upgrade_packs:ugpacks", {
|
||||||
return
|
title = "Upgrade Packs",
|
||||||
|
get = function(self, player, context)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
return sfinv.make_formspec(player, context,
|
||||||
|
"label[3,0;Upgrade Packs]" ..
|
||||||
|
"list[current_player;ugpacks;3,1;2,2;]" ..
|
||||||
|
"list[current_player;main;0,5;8,4;]" ..
|
||||||
|
"listring[]"
|
||||||
|
, false)
|
||||||
|
end
|
||||||
|
})
|
@ -13,9 +13,9 @@ unified_inventory.register_page("ugpacks", {
|
|||||||
local y = perplayer_formspec.formspec_y
|
local y = perplayer_formspec.formspec_y
|
||||||
|
|
||||||
return { formspec = (
|
return { formspec = (
|
||||||
"label[1,0;Upgrade Packs]"..
|
"label[3,0;Upgrade Packs]" ..
|
||||||
"list[current_player;ugpacks;1," ..(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]"
|
||||||
)}
|
)}
|
||||||
end
|
end
|
||||||
|
6
init.lua
6
init.lua
@ -9,6 +9,8 @@ if minetest.get_modpath("unified_inventory") 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")
|
||||||
|
else
|
||||||
|
dofile(modpath .. "/gui_plain.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
upgrade_packs.register_pack("upgrade_packs:hp_10", "health", {
|
upgrade_packs.register_pack("upgrade_packs:hp_10", "health", {
|
||||||
@ -51,12 +53,11 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user)
|
minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user)
|
||||||
print(dump(hp_change))
|
|
||||||
if hp_change == 0 then
|
if hp_change == 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- Undo some of the wear when eating instead of dying
|
-- Undo some of the wear when eating instead of dying
|
||||||
upgrade_packs.add_wear(user, "health", hp_change * -10)
|
upgrade_packs.add_wear(user, "health", hp_change * -2)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_player_hpchange(function(player, hp_change, reason)
|
minetest.register_on_player_hpchange(function(player, hp_change, reason)
|
||||||
@ -71,7 +72,6 @@ minetest.register_on_player_hpchange(function(player, hp_change, reason)
|
|||||||
end, false)
|
end, false)
|
||||||
|
|
||||||
minetest.register_allow_player_inventory_action(function(player, action, inv, data)
|
minetest.register_allow_player_inventory_action(function(player, action, inv, data)
|
||||||
print(dump(data))
|
|
||||||
if data.to_list ~= "ugpacks" then
|
if data.to_list ~= "ugpacks" then
|
||||||
return -- Not interesting for this mod
|
return -- Not interesting for this mod
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user