mirror of
https://github.com/minetest-mods/skinsdb.git
synced 2024-12-22 23:40:18 +01:00
changes needed for character_creator support
This commit is contained in:
parent
920061c0f1
commit
57b815f91f
9
api.lua
9
api.lua
@ -26,12 +26,5 @@ end
|
||||
-- update visuals
|
||||
skins.update_player_skin = function(player)
|
||||
local skin = skins.get_player_skin(player)
|
||||
player:set_properties({
|
||||
textures = {skin:get_texture()},
|
||||
})
|
||||
skin:set_skin(player)
|
||||
end
|
||||
|
||||
-- Update skin on join
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
skins.update_player_skin(player)
|
||||
end)
|
||||
|
7
init.lua
7
init.lua
@ -26,10 +26,15 @@ end
|
||||
if minetest.global_exists("armor") then
|
||||
armor.get_player_skin = function(self, name)
|
||||
local skin = skins.get_player_skin(minetest.get_player_by_name(name))
|
||||
return skin:get_meta("_key") --3d_armor adds a ".png" but it should be compatible in most cases
|
||||
return skin:get_texture()
|
||||
end
|
||||
armor.get_preview = function(self, name)
|
||||
local skin = skins.get_player_skin(minetest.get_player_by_name(name))
|
||||
return skin:get_preview()
|
||||
end
|
||||
end
|
||||
|
||||
-- Update skin on join
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
skins.update_player_skin(player)
|
||||
end)
|
||||
|
@ -9,15 +9,16 @@ end
|
||||
local function get_formspec(player, context)
|
||||
local name = player:get_player_name()
|
||||
local skin = skins.get_player_skin(player)
|
||||
|
||||
-- overview page
|
||||
local formspec = "image[0,.75;1,2;"..skin:get_preview().."]"
|
||||
.."label[6,.5;"..S("Raw texture")..":]"
|
||||
.."image[6,1;2,1;"..skin:get_texture().."]"
|
||||
|
||||
local texture = skin:get_texture()
|
||||
local m_name = skin:get_meta_string("name")
|
||||
local m_author = skin:get_meta_string("author")
|
||||
local m_license = skin:get_meta_string("license")
|
||||
-- overview page
|
||||
local formspec = "image[0,.75;1,2;"..skin:get_preview().."]"
|
||||
if texture then
|
||||
formspec = formspec.."label[6,.5;"..S("Raw texture")..":]"
|
||||
.."image[6,1;2,1;"..skin:get_texture().."]"
|
||||
end
|
||||
if m_name ~= "" then
|
||||
formspec = formspec.."label[2,.5;"..S("Name")..": "..minetest.formspec_escape(m_name).."]"
|
||||
end
|
||||
@ -62,10 +63,10 @@ local function get_formspec(player, context)
|
||||
page_next = 1
|
||||
end
|
||||
local page_list = ""
|
||||
dropdown_values = {}
|
||||
context.dropdown_values = {}
|
||||
for pg=1, context.total_pages do
|
||||
local pagename = S("Page").." "..pg.."/"..context.total_pages
|
||||
dropdown_values[pagename] = pg
|
||||
context.dropdown_values[pagename] = pg
|
||||
if pg > 1 then page_list = page_list.."," end
|
||||
page_list = page_list..pagename
|
||||
end
|
||||
@ -106,7 +107,7 @@ sfinv.register_page("skins:overview", {
|
||||
end
|
||||
end
|
||||
if fields.skins_selpg then
|
||||
context.skins_page = tonumber(dropdown_values[fields.skins_selpg])
|
||||
context.skins_page = tonumber(context.dropdown_values[fields.skins_selpg])
|
||||
sfinv.set_player_inventory_formspec(player)
|
||||
return
|
||||
end
|
||||
|
@ -54,3 +54,15 @@ end
|
||||
function skin_class:get_preview()
|
||||
return self._preview or "player.png"
|
||||
end
|
||||
|
||||
function skin_class:set_skin(player)
|
||||
player:set_properties({
|
||||
visual_size = {
|
||||
x = 1,
|
||||
y = 1
|
||||
}
|
||||
})
|
||||
player:set_properties({
|
||||
textures = {self:get_texture()},
|
||||
})
|
||||
end
|
||||
|
27
skinlist.lua
27
skinlist.lua
@ -1,7 +1,6 @@
|
||||
|
||||
local skins_dir_list = minetest.get_dir_list(skins.modpath.."/textures")
|
||||
local unsorted_skinslist = {}
|
||||
local sorted_skinslist
|
||||
|
||||
for _, fn in pairs(skins_dir_list) do
|
||||
local nameparts = string.gsub(fn, "[.]", "_"):split("_")
|
||||
|
||||
@ -43,28 +42,20 @@ for _, fn in pairs(skins_dir_list) do
|
||||
else
|
||||
skin_obj:set_meta("name", name)
|
||||
end
|
||||
table.insert(unsorted_skinslist, skin_obj)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- get skinlist. If assignment given ("mod:wardrobe" or "player:bell07") select skins matches the assignment. select_unassigned selects the skins without any assignment too
|
||||
function skins.get_skinlist(assignment, select_unassigned)
|
||||
-- sort on demand
|
||||
if not sorted_skinslist then
|
||||
table.sort(unsorted_skinslist, function(a,b) return a:get_meta("_sort_id") < b:get_meta("_sort_id") end)
|
||||
sorted_skinslist = unsorted_skinslist
|
||||
end
|
||||
if not assignment then
|
||||
return sorted_skinslist
|
||||
else
|
||||
local ret = {}
|
||||
for _, skin in ipairs(sorted_skinslist) do
|
||||
if assignment == skin:get_meta("assignment") or
|
||||
(select_unassigned and skin:get_meta("assignment") == nil) then
|
||||
table.insert(ret, skin)
|
||||
end
|
||||
local skinslist = {}
|
||||
for _, skin in pairs(skins.meta) do
|
||||
if not assignment or
|
||||
assignment == skin:get_meta("assignment") or
|
||||
(select_unassigned and skin:get_meta("assignment") == nil) then
|
||||
table.insert(skinslist, skin)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
table.sort(skinslist, function(a,b) return a:get_meta("_sort_id") < b:get_meta("_sort_id") end)
|
||||
return skinslist
|
||||
end
|
||||
|
@ -12,15 +12,15 @@ unified_inventory.register_page("skins", {
|
||||
get_formspec = function(player)
|
||||
local name = player:get_player_name()
|
||||
local skin = skins.get_player_skin(player)
|
||||
local formspec = ("background[0.06,0.99;7.92,7.52;ui_misc_form.png]"
|
||||
.."image[0,.75;1,2;"..skin:get_preview().."]"
|
||||
.."label[6,.5;"..S("Raw texture")..":]"
|
||||
.."image[6,1;2,1;"..skin:get_texture().."]")
|
||||
|
||||
|
||||
local texture = skin:get_texture()
|
||||
local m_name = skin:get_meta_string("name")
|
||||
local m_author = skin:get_meta_string("author")
|
||||
local m_license = skin:get_meta_string("license")
|
||||
local formspec = "background[0.06,0.99;7.92,7.52;ui_misc_form.png]".."image[0,.75;1,2;"..skin:get_preview().."]"
|
||||
if texture then
|
||||
formspec=formspec.."label[6,.5;"..S("Raw texture")..":]"
|
||||
.."image[6,1;2,1;"..texture.."]"
|
||||
end
|
||||
if m_name ~= "" then
|
||||
formspec = formspec.."label[2,.5;"..S("Name")..": "..minetest.formspec_escape(m_name).."]"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user