forked from VoxeLibre/VoxeLibre
Get rid of the 2d preview
This commit is contained in:
parent
f6f0690253
commit
0e42e58901
|
@ -48,7 +48,7 @@ mcl_armor.register_set({
|
||||||
enchantability = 15,
|
enchantability = 15,
|
||||||
|
|
||||||
--this define how much each piece of armor protect the player
|
--this define how much each piece of armor protect the player
|
||||||
--these points will be shown in the HUD (chestplate bar above the health bar)
|
--these points will be shown in the HUD (chestplate bar above the health bar)
|
||||||
points = {
|
points = {
|
||||||
head = 1,
|
head = 1,
|
||||||
torso = 3,
|
torso = 3,
|
||||||
|
@ -87,23 +87,15 @@ mcl_armor.register_set({
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
--WARNING: 2d preview is deprecated and will be removed soon
|
--specify textures that will be shown in player inventory
|
||||||
--specify textures that will be shown in player inventory then you disabled the 3d player inventory preview
|
--its similar to how works the textures field except you can't use functions
|
||||||
--its similar to how works the textures field
|
inventory = {
|
||||||
previews = {
|
head = "inv_dummy_texture.png", --default: "<modname>_inv_helmet_<material>.png"
|
||||||
head = "dummy_texture.png", --default: "<modname>_helmet_<material>_preview.png"
|
torso = "inv_dummy_texture.png", --default: "<modname>_inv_chestplate_<material>.png"
|
||||||
torso = "dummy_texture.png", --default: "<modname>_chestplate_<material>_preview.png"
|
legs = "inv_dummy_texture.png", --default: "<modname>_inv_leggings_<material>.png"
|
||||||
legs = "dummy_texture.png", --default: "<modname>_leggings_<material>_preview.png"
|
feet = "inv_dummy_texture.png", --default: "<modname>_inv_boots_<material>.png"
|
||||||
feet = "dummy_texture.png", --default: "<modname>_boots_<material>_preview.png"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
--inventory textures aren't definable using a table similar to textures or previews
|
|
||||||
--you are forced to use the default texture names which are:
|
|
||||||
--head: "<modname>_inv_helmet_<material>.png
|
|
||||||
--torso: "<modname>_inv_chestplate_<material>.png
|
|
||||||
--legs: "<modname>_inv_leggings_<material>.png
|
|
||||||
--feet: "<modname>_inv_boots_<material>.png
|
|
||||||
|
|
||||||
--this callback table allow you to define functions that will be called each time an entity equip an armor piece or the mcl_armor.on_equip() function is called
|
--this callback table allow you to define functions that will be called each time an entity equip an armor piece or the mcl_armor.on_equip() function is called
|
||||||
--the functions accept two arguments: obj and itemstack
|
--the functions accept two arguments: obj and itemstack
|
||||||
on_equip_callbacks = {
|
on_equip_callbacks = {
|
||||||
|
@ -134,12 +126,12 @@ mcl_armor.register_set({
|
||||||
craft_material = "mcl_mobitems:leather",
|
craft_material = "mcl_mobitems:leather",
|
||||||
|
|
||||||
--this is used to generate cooking crafts for each piece of armor
|
--this is used to generate cooking crafts for each piece of armor
|
||||||
--if set to nil no craft will be added
|
--if set to nil no craft will be added
|
||||||
cook_material = "mcl_core:gold_nugget", --cooking any piece of this armor will output a gold nugged
|
cook_material = "mcl_core:gold_nugget", --cooking any piece of this armor will output a gold nugged
|
||||||
|
|
||||||
--this is used for allowing each piece of the armor to be repaired by using an anvil with repair_material as aditionnal material
|
--this is used for allowing each piece of the armor to be repaired by using an anvil with repair_material as aditionnal material
|
||||||
--it basicaly set the _repair_material item field of each piece of the armor
|
--it basicaly set the _repair_material item field of each piece of the armor
|
||||||
--if set to nil no repair material will be added
|
--if set to nil no repair material will be added
|
||||||
repair_material = "mcl_core:iron_ingot",
|
repair_material = "mcl_core:iron_ingot",
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
@ -179,7 +171,7 @@ minetest.register_tool("dummy_mod:random_armor", {
|
||||||
},
|
},
|
||||||
|
|
||||||
--these fields should be initialised like that in most cases
|
--these fields should be initialised like that in most cases
|
||||||
--mcl_armor.equip_on_use is a function that try to equip the piece of armor you have in hand inside the right armor slot if the slot is empty
|
--mcl_armor.equip_on_use is a function that try to equip the piece of armor you have in hand inside the right armor slot if the slot is empty
|
||||||
on_place = mcl_armor.equip_on_use,
|
on_place = mcl_armor.equip_on_use,
|
||||||
on_secondary_use = mcl_armor.equip_on_use,
|
on_secondary_use = mcl_armor.equip_on_use,
|
||||||
|
|
||||||
|
@ -263,7 +255,7 @@ mcl_armor.register_protection_enchantment({
|
||||||
max_level = 4,
|
max_level = 4,
|
||||||
|
|
||||||
--which enchants this enchant will not be compatible with
|
--which enchants this enchant will not be compatible with
|
||||||
--each of these values is a enchant id
|
--each of these values is a enchant id
|
||||||
incompatible = {blast_protection = true, fire_protection = true, projectile_protection = true},
|
incompatible = {blast_protection = true, fire_protection = true, projectile_protection = true},
|
||||||
|
|
||||||
--how much will the enchant consume from the enchantability group of the armor item
|
--how much will the enchant consume from the enchantability group of the armor item
|
||||||
|
@ -284,7 +276,7 @@ mcl_armor.register_protection_enchantment({
|
||||||
factor = 1,
|
factor = 1,
|
||||||
|
|
||||||
--restrict damage to one type
|
--restrict damage to one type
|
||||||
--allow the enchant to only protect of one type of damage
|
--allow the enchant to only protect of one type of damage
|
||||||
damage_type = "magic",
|
damage_type = "magic",
|
||||||
|
|
||||||
--restrict damage to one category
|
--restrict damage to one category
|
||||||
|
|
|
@ -220,17 +220,6 @@ function mcl_armor.update(obj)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local preview = def._mcl_armor_preview
|
|
||||||
|
|
||||||
if obj:is_player() and preview then
|
|
||||||
if type(preview) == "function" then
|
|
||||||
preview = preview(obj, itemstack)
|
|
||||||
end
|
|
||||||
if preview then
|
|
||||||
info.preview = "(player.png^[opacity:0^" .. def._mcl_armor_preview .. ")" .. (info.preview and "^" .. info.preview or "" )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
info.points = info.points + minetest.get_item_group(itemname, "mcl_armor_points")
|
info.points = info.points + minetest.get_item_group(itemname, "mcl_armor_points")
|
||||||
|
|
||||||
local mob_range_mob = def._mcl_armor_mob_range_mob
|
local mob_range_mob = def._mcl_armor_mob_range_mob
|
||||||
|
@ -253,8 +242,6 @@ function mcl_armor.update(obj)
|
||||||
info.texture = info.texture or "blank.png"
|
info.texture = info.texture or "blank.png"
|
||||||
|
|
||||||
if obj:is_player() then
|
if obj:is_player() then
|
||||||
info.preview = info.preview or "blank.png"
|
|
||||||
|
|
||||||
mcl_armor.update_player(obj, info)
|
mcl_armor.update_player(obj, info)
|
||||||
else
|
else
|
||||||
local luaentity = obj:get_luaentity()
|
local luaentity = obj:get_luaentity()
|
||||||
|
|
|
@ -63,7 +63,7 @@ mcl_player.player_register_model("mcl_armor_character_female.b3d", {
|
||||||
})
|
})
|
||||||
|
|
||||||
function mcl_armor.update_player(player, info)
|
function mcl_armor.update_player(player, info)
|
||||||
mcl_player.player_set_armor(player, info.texture, info.preview)
|
mcl_player.player_set_armor(player, info.texture)
|
||||||
|
|
||||||
local meta = player:get_meta()
|
local meta = player:get_meta()
|
||||||
meta:set_int("mcl_armor:armor_points", info.points)
|
meta:set_int("mcl_armor:armor_points", info.points)
|
||||||
|
|
|
@ -280,9 +280,6 @@ function mcl_enchanting.initialize()
|
||||||
if new_def._mcl_armor_texture and not type(new_def._mcl_armor_texture) == "function" then
|
if new_def._mcl_armor_texture and not type(new_def._mcl_armor_texture) == "function" then
|
||||||
new_def._mcl_armor_texture = new_def._mcl_armor_texture .. mcl_enchanting.overlay
|
new_def._mcl_armor_texture = new_def._mcl_armor_texture .. mcl_enchanting.overlay
|
||||||
end
|
end
|
||||||
if new_def._mcl_armor_preview and not type(new_def._mcl_armor_preview) == "function" then
|
|
||||||
new_def._mcl_armor_preview = new_def._mcl_armor_preview .. mcl_enchanting.overlay
|
|
||||||
end
|
|
||||||
|
|
||||||
new_def._mcl_enchanting_enchanted_tool = new_name
|
new_def._mcl_enchanting_enchanted_tool = new_name
|
||||||
new_def.after_use = get_after_use_callback(itemdef)
|
new_def.after_use = get_after_use_callback(itemdef)
|
||||||
|
|
|
@ -123,7 +123,6 @@ pumpkin_face_base_def._mcl_armor_mob_range_factor = 0
|
||||||
pumpkin_face_base_def._mcl_armor_mob_range_mob = "mobs_mc:enderman"
|
pumpkin_face_base_def._mcl_armor_mob_range_mob = "mobs_mc:enderman"
|
||||||
pumpkin_face_base_def._mcl_armor_element = "head"
|
pumpkin_face_base_def._mcl_armor_element = "head"
|
||||||
pumpkin_face_base_def._mcl_armor_texture = "mcl_farming_pumpkin_face.png"
|
pumpkin_face_base_def._mcl_armor_texture = "mcl_farming_pumpkin_face.png"
|
||||||
pumpkin_face_base_def._mcl_armor_preview = "mcl_farming_pumpkin_face_preview.png"
|
|
||||||
|
|
||||||
if minetest.get_modpath("mcl_armor") then
|
if minetest.get_modpath("mcl_armor") then
|
||||||
local pumpkin_hud = {}
|
local pumpkin_hud = {}
|
||||||
|
|
|
@ -113,7 +113,6 @@ local function addhead(name, texture, desc, longdesc, rangemob, rangefactor)
|
||||||
_mcl_armor_mob_range_factor = rangefactor,
|
_mcl_armor_mob_range_factor = rangefactor,
|
||||||
_mcl_armor_element = "head",
|
_mcl_armor_element = "head",
|
||||||
_mcl_armor_texture = "mcl_heads_" .. name .. ".png",
|
_mcl_armor_texture = "mcl_heads_" .. name .. ".png",
|
||||||
_mcl_armor_preview = "mcl_heads_" .. name .. "_preview.png",
|
|
||||||
_mcl_blast_resistance = 1,
|
_mcl_blast_resistance = 1,
|
||||||
_mcl_hardness = 1,
|
_mcl_hardness = 1,
|
||||||
})
|
})
|
||||||
|
|
|
@ -95,37 +95,19 @@ local function set_texture(player, index, texture)
|
||||||
player:set_properties({textures = textures})
|
player:set_properties({textures = textures})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function set_preview(player, field, preview)
|
|
||||||
player:get_meta():set_string("mcl_player:" .. field .. "_preview", preview)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mcl_player.player_set_skin(player, texture, preview)
|
function mcl_player.player_set_skin(player, texture)
|
||||||
set_texture(player, 1, texture)
|
set_texture(player, 1, texture)
|
||||||
set_preview(player, "skin", preview)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_player.player_set_armor(player, texture, preview)
|
function mcl_player.player_set_armor(player, texture)
|
||||||
set_texture(player, 2, texture)
|
set_texture(player, 2, texture)
|
||||||
set_preview(player, "armor", preview)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_player.player_set_wielditem(player, texture)
|
function mcl_player.player_set_wielditem(player, texture)
|
||||||
set_texture(player, 3, texture)
|
set_texture(player, 3, texture)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_player.player_get_preview(player)
|
|
||||||
local preview = player:get_meta():get_string("mcl_player:skin_preview")
|
|
||||||
if preview == "" then
|
|
||||||
preview = "player.png"
|
|
||||||
end
|
|
||||||
local armor_preview = player:get_meta():set_string("mcl_player:armor_preview")
|
|
||||||
if armor_preview ~= "" then
|
|
||||||
preview = preview .. "^" .. armor_preview
|
|
||||||
end
|
|
||||||
return preview
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function mcl_player.get_player_formspec_model(player, x, y, w, h, fsname)
|
function mcl_player.get_player_formspec_model(player, x, y, w, h, fsname)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local model = player_model[name]
|
local model = player_model[name]
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
!mcl_skins_character_1.png
|
||||||
|
textures/mcl_skins_character_*
|
|
@ -3,7 +3,7 @@
|
||||||
local modname = minetest.get_current_modname()
|
local modname = minetest.get_current_modname()
|
||||||
|
|
||||||
mcl_skins = {
|
mcl_skins = {
|
||||||
skins = {}, list = {}, previews = {}, meta = {}, has_preview = {},
|
skins = {}, list = {}, meta = {},
|
||||||
modpath = minetest.get_modpath(modname),
|
modpath = minetest.get_modpath(modname),
|
||||||
skin_count = 0, -- counter of _custom_ skins (all skins except character.png)
|
skin_count = 0, -- counter of _custom_ skins (all skins except character.png)
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,8 @@ while true do
|
||||||
|
|
||||||
if id == 0 then
|
if id == 0 then
|
||||||
skin = "character"
|
skin = "character"
|
||||||
mcl_skins.has_preview[id] = true
|
|
||||||
else
|
else
|
||||||
skin = "mcl_skins_character_" .. id
|
skin = "mcl_skins_character_" .. id
|
||||||
local preview = "mcl_skins_player_" .. id
|
|
||||||
|
|
||||||
-- Does skin file exist?
|
-- Does skin file exist?
|
||||||
f = io.open(mcl_skins.modpath .. "/textures/" .. skin .. ".png")
|
f = io.open(mcl_skins.modpath .. "/textures/" .. skin .. ".png")
|
||||||
|
@ -31,16 +29,6 @@ while true do
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Does skin preview file exist?
|
|
||||||
local file_preview = io.open(mcl_skins.modpath .. "/textures/" .. preview .. ".png")
|
|
||||||
if file_preview == nil then
|
|
||||||
minetest.log("warning", "[mcl_skins] Player skin #"..id.." does not have preview image (player_"..id..".png)")
|
|
||||||
mcl_skins.has_preview[id] = false
|
|
||||||
else
|
|
||||||
mcl_skins.has_preview[id] = true
|
|
||||||
file_preview:close()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_skins.list[id] = skin
|
mcl_skins.list[id] = skin
|
||||||
|
@ -89,12 +77,11 @@ function mcl_skins.set_player_skin(player, skin_id)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
local skin, preview
|
local skin
|
||||||
if skin_id == nil or type(skin_id) ~= "number" or skin_id < 0 or skin_id > mcl_skins.skin_count then
|
if skin_id == nil or type(skin_id) ~= "number" or skin_id < 0 or skin_id > mcl_skins.skin_count then
|
||||||
return false
|
return false
|
||||||
elseif skin_id == 0 then
|
elseif skin_id == 0 then
|
||||||
skin = "character"
|
skin = "character"
|
||||||
preview = "player"
|
|
||||||
mcl_player.player_set_model(player, "mcl_armor_character.b3d")
|
mcl_player.player_set_model(player, "mcl_armor_character.b3d")
|
||||||
else
|
else
|
||||||
skin = "mcl_skins_character_" .. tostring(skin_id)
|
skin = "mcl_skins_character_" .. tostring(skin_id)
|
||||||
|
@ -104,16 +91,9 @@ function mcl_skins.set_player_skin(player, skin_id)
|
||||||
else
|
else
|
||||||
mcl_player.player_set_model(player, "mcl_armor_character.b3d")
|
mcl_player.player_set_model(player, "mcl_armor_character.b3d")
|
||||||
end
|
end
|
||||||
if mcl_skins.has_preview[skin_id] then
|
|
||||||
preview = "mcl_skins_player_" .. tostring(skin_id)
|
|
||||||
else
|
|
||||||
-- Fallback preview image if preview image is missing
|
|
||||||
preview = "mcl_skins_player_dummy"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
--local skin_file = skin .. ".png"
|
--local skin_file = skin .. ".png"
|
||||||
mcl_skins.skins[playername] = skin
|
mcl_skins.skins[playername] = skin
|
||||||
mcl_skins.previews[playername] = preview
|
|
||||||
player:get_meta():set_string("mcl_skins:skin_id", tostring(skin_id))
|
player:get_meta():set_string("mcl_skins:skin_id", tostring(skin_id))
|
||||||
mcl_skins.update_player_skin(player)
|
mcl_skins.update_player_skin(player)
|
||||||
if has_mcl_inventory then
|
if has_mcl_inventory then
|
||||||
|
@ -131,7 +111,7 @@ function mcl_skins.update_player_skin(player)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
mcl_player.player_set_skin(player, mcl_skins.skins[playername] .. ".png", mcl_skins.previews[playername] .. ".png")
|
mcl_player.player_set_skin(player, mcl_skins.skins[playername] .. ".png")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- load player skin on join
|
-- load player skin on join
|
||||||
|
@ -259,7 +239,11 @@ function mcl_skins.show_formspec(playername)
|
||||||
|
|
||||||
formspec = formspec .. ";" .. selected .. ";false]"
|
formspec = formspec .. ";" .. selected .. ";false]"
|
||||||
|
|
||||||
formspec = formspec .. "image[0,0;1.35,2.7;" .. mcl_skins.previews[playername] .. ".png]"
|
local player = minetest.get_player_by_name(playername)
|
||||||
|
if player then
|
||||||
|
--maybe the function could accept both player object and player name?
|
||||||
|
formspec = formspec .. mcl_player.get_player_formspec_model(player, 0, 0, 1.35, 2.7, "mcl_skins:skin_select")
|
||||||
|
end
|
||||||
|
|
||||||
if meta then
|
if meta then
|
||||||
if meta.name and meta.name ~= "" then
|
if meta.name and meta.name ~= "" then
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 982 B |
Loading…
Reference in New Issue