1
0
Fork 0

3D Player preview in inventory

This commit is contained in:
Lizzy Fleckenstein 2021-02-08 20:13:08 +01:00
parent 26037157f8
commit b36db2044f
4 changed files with 47 additions and 27 deletions

View File

@ -330,22 +330,27 @@ mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, inv_siz
inv_bg = "crafting_inventory_creative_survival.png"
-- Show armor and player image
local img, img_player
if mod_player then
img_player = mcl_player.player_get_preview(player)
local player_preview
if minetest.settings:get_bool("3d_player_preview", true) then
player_preview = mcl_player.get_player_formspec_model(player, 3.9, 1.4, 1.2333, 2.4666, "")
else
img_player = "player.png"
end
img = img_player
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 = img_player..s1
local img, img_player
if mod_player then
img_player = mcl_player.player_get_preview(player)
else
img_player = "player.png"
end
img = img_player
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 = img_player..s1
end
player_preview = "image[3.9,1.4;1.2333,2.4666;"..img.."]"
end
end
-- Background images for armor slots (hide if occupied)

View File

@ -64,22 +64,27 @@ local function set_inventory(player, armor_change_only)
local player_name = player:get_player_name()
-- Show armor and player image
local img, img_player
if mod_player then
img_player = mcl_player.player_get_preview(player)
local player_preview
if minetest.settings:get_bool("3d_player_preview", true) then
player_preview = mcl_player.get_player_formspec_model(player, 1.0, 0.0, 2.25, 4.5, "")
else
img_player = "player.png"
end
img = img_player
local player_preview = "image[0.6,0.2;2,4;"..img.."]"
if show_armor and armor.textures[player_name] and armor.textures[player_name].preview then
img = armor.textures[player_name].preview
local s1 = img:find("character_preview")
if s1 ~= nil then
s1 = img:sub(s1+21)
img = img_player..s1
local img, img_player
if mod_player then
img_player = mcl_player.player_get_preview(player)
else
img_player = "player.png"
end
img = img_player
player_preview = "image[0.6,0.2;2,4;"..img.."]"
if show_armor and armor.textures[player_name] and armor.textures[player_name].preview then
img = armor.textures[player_name].preview
local s1 = img:find("character_preview")
if s1 ~= nil then
s1 = img:sub(s1+21)
img = img_player..s1
end
player_preview = "image[1.1,0.2;2,4;"..img.."]"
end
player_preview = "image[1.1,0.2;2,4;"..img.."]"
end
local armor_slots = {"helmet", "chestplate", "leggings", "boots"}

View File

@ -93,6 +93,13 @@ function mcl_player.player_get_preview(player)
end
end
function mcl_player.get_player_formspec_model(player, x, y, w, h, fsname)
local name = player:get_player_name()
local model = player_model[name]
local anim = models[model].animations[player_anim[name]]
return "model[" .. x .. "," .. y .. ";" .. w .. "," .. h .. ";" .. fsname .. ";" .. model .. ";" .. table.concat(player_textures[name], ",") .. ";0," .. 180 .. ";false;false;" .. anim.x .. "," .. anim.y .. "]"
end
function mcl_player.player_set_animation(player, anim_name, speed)
local name = player:get_player_name()
if player_anim[name] == anim_name then

View File

@ -94,6 +94,9 @@ fire_animation_frames (Fire Animation Frames) int 8
# Whether to animate chests when open / close
animated_chests (Animated chests) bool true
# Whether to preview the player in inventory in 3D (requires Minetest 5.4)
3d_player_preview (3D Player preview) bool true
[Experimental]
# Whether ice is translucent. If disabled, ice is fully opaque.
#