1
0
Fork 0

Player skins: Update inventory preview (part 2)

This commit is contained in:
Wuzzy 2019-03-05 10:29:49 +01:00
parent 2c5038ad05
commit e47bd634d4
4 changed files with 42 additions and 0 deletions

View File

@ -570,6 +570,38 @@ if minetest.settings:get_bool("creative_mode") then
end end
end end
mcl_inventory.update_inventory_formspec = function(player)
local page = nil
local name = player:get_player_name()
if players[name].page then
page = players[name].page
else
page = "nix"
end
-- Figure out current scroll bar from formspec
local formspec = player:get_inventory_formspec()
local start_i = players[name].start_i
local inv_size
if page == "nix" then
local inv = minetest.get_inventory({type="detached", name="creative_"..name})
inv_size = inv:get_size("main")
elseif page ~= nil and page ~= "inv" then
inv_size = #(inventory_lists[page])
else
inv_size = 0
end
local filter = players[name].filter
if filter == nil then
filter = ""
end
mcl_inventory.set_creative_formspec(player, start_i, start_i / (9*5) + 1, inv_size, false, page, filter)
end
end end
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)

View File

@ -127,6 +127,12 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end end
end) end)
if not minetest.settings:get_bool("creative_mode") then
mcl_inventory.update_inventory_formspec = function(player)
set_inventory(player)
end
end
-- Drop crafting grid items on leaving -- Drop crafting grid items on leaving
minetest.register_on_leaveplayer(function(player) minetest.register_on_leaveplayer(function(player)
return_fields(player, "craft") return_fields(player, "craft")

View File

@ -1,3 +1,4 @@
mcl_player mcl_player
mcl_inventory?
intllib? intllib?
3d_armor? 3d_armor?

View File

@ -72,6 +72,9 @@ skins.set_player_skin = function(player, skin_id)
armor.textures[playername].skin = skin .. ".png" armor.textures[playername].skin = skin .. ".png"
armor:update_player_visuals(player) armor:update_player_visuals(player)
end end
if minetest.get_modpath("mcl_inventory") then
mcl_inventory.update_inventory_formspec(player)
end
return true return true
end end