mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 04:21:07 +01:00
Show player preview in creative inventory
This commit is contained in:
parent
e296b91936
commit
04daa1295b
2 changed files with 23 additions and 11 deletions
|
@ -210,6 +210,22 @@ mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, show, p
|
||||||
if name == "inv" then
|
if name == "inv" then
|
||||||
inv_bg = "crafting_inventory_creative_survival.png"
|
inv_bg = "crafting_inventory_creative_survival.png"
|
||||||
|
|
||||||
|
-- Show armor and player image
|
||||||
|
local show_armor = minetest.get_modpath("3d_armor")
|
||||||
|
-- TODO: Use player.png to allow for custom skins
|
||||||
|
local img = "crafting_player2d.png"
|
||||||
|
local armor_img = ""
|
||||||
|
local player_preview = "image[3.9,1.4;1.2333,2.4666;"..img.."]"
|
||||||
|
if show_armor and armor.textures[playername] and armor.textures[playername].preview then
|
||||||
|
img = armor.textures[playername].preview
|
||||||
|
local s1 = img:find("character_preview")
|
||||||
|
if s1 ~= nil then
|
||||||
|
s1 = img:sub(s1+21)
|
||||||
|
img = "crafting_player2d.png"..s1
|
||||||
|
end
|
||||||
|
player_preview = "image[3.9,1.4;1.2333,2.4666;"..img.."]"
|
||||||
|
end
|
||||||
|
|
||||||
-- Background images for armor slots (hide if occupied)
|
-- Background images for armor slots (hide if occupied)
|
||||||
local armor_slot_imgs = ""
|
local armor_slot_imgs = ""
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
|
@ -234,6 +250,8 @@ mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, show, p
|
||||||
"list[detached:"..playername.."_armor;armor;5.5,1.3;1,1;3]"..
|
"list[detached:"..playername.."_armor;armor;5.5,1.3;1,1;3]"..
|
||||||
"list[detached:"..playername.."_armor;armor;5.5,2.75;1,1;4]"..
|
"list[detached:"..playername.."_armor;armor;5.5,2.75;1,1;4]"..
|
||||||
armor_slot_imgs..
|
armor_slot_imgs..
|
||||||
|
-- player preview
|
||||||
|
player_preview..
|
||||||
-- crafting guide button
|
-- crafting guide button
|
||||||
"image_button[9,1;1,1;craftguide_book.png;__mcl_craftguide;]"..
|
"image_button[9,1;1,1;craftguide_book.png;__mcl_craftguide;]"..
|
||||||
"tooltip[__mcl_craftguide;Show crafting recipes]"..
|
"tooltip[__mcl_craftguide;Show crafting recipes]"..
|
||||||
|
|
|
@ -31,8 +31,6 @@ local function drop_fields(player, name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local player_armor = {}
|
|
||||||
|
|
||||||
local function update_armor(player)
|
local function update_armor(player)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -47,16 +45,12 @@ local function set_inventory(player)
|
||||||
inv:set_size("craft", 4)
|
inv:set_size("craft", 4)
|
||||||
|
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
|
|
||||||
|
-- Show armor and player image
|
||||||
-- TODO: Use player.png to allow for custom skins
|
-- TODO: Use player.png to allow for custom skins
|
||||||
local img = "crafting_player2d.png"
|
local img = "crafting_player2d.png"
|
||||||
local armor_img = ""
|
local armor_img = ""
|
||||||
if show_armor then
|
local player_preview = "image[0.6,0.2;2,4;"..img.."]"
|
||||||
armor_img = ""
|
|
||||||
if player_armor[player_name] ~= nil then
|
|
||||||
img = img .. player_armor[player_name]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local img_element = "image[0.6,0.2;3,4;"..img.."]"
|
|
||||||
if show_armor and armor.textures[player_name] and armor.textures[player_name].preview then
|
if show_armor and armor.textures[player_name] and armor.textures[player_name].preview then
|
||||||
img = armor.textures[player_name].preview
|
img = armor.textures[player_name].preview
|
||||||
local s1 = img:find("character_preview")
|
local s1 = img:find("character_preview")
|
||||||
|
@ -64,7 +58,7 @@ local function set_inventory(player)
|
||||||
s1 = img:sub(s1+21)
|
s1 = img:sub(s1+21)
|
||||||
img = "crafting_player2d.png"..s1
|
img = "crafting_player2d.png"..s1
|
||||||
end
|
end
|
||||||
img_element = "image[1.1,0.2;2,4;"..img.."]"
|
player_preview = "image[1.1,0.2;2,4;"..img.."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local armor_slots = {"head", "torso", "legs", "feet"}
|
local armor_slots = {"head", "torso", "legs", "feet"}
|
||||||
|
@ -78,7 +72,7 @@ local function set_inventory(player)
|
||||||
local form = "size[9,8.75]"..
|
local form = "size[9,8.75]"..
|
||||||
"background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png^crafting_inventory.png"..armor_img.."]"..
|
"background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png^crafting_inventory.png"..armor_img.."]"..
|
||||||
mcl_vars.inventory_header..
|
mcl_vars.inventory_header..
|
||||||
img_element..
|
player_preview..
|
||||||
--armor
|
--armor
|
||||||
"list[detached:"..player_name.."_armor;armor;0,0;1,1;1]"..
|
"list[detached:"..player_name.."_armor;armor;0,0;1,1;1]"..
|
||||||
"list[detached:"..player_name.."_armor;armor;0,1;1,1;2]"..
|
"list[detached:"..player_name.."_armor;armor;0,1;1,1;2]"..
|
||||||
|
|
Loading…
Reference in a new issue