2014-03-17 06:26:58 +01:00
|
|
|
-- Unified Skins for Minetest - based modified Bags from unfied_inventory and skins from inventory_plus
|
|
|
|
|
|
|
|
-- Copyright (c) 2012 cornernote, Dean Montgomery
|
2017-06-15 18:19:47 +02:00
|
|
|
-- Rework 2017 by bell07
|
2014-03-17 06:26:58 +01:00
|
|
|
-- License: GPLv3
|
2016-09-05 19:20:16 +02:00
|
|
|
|
2017-02-09 23:06:25 +01:00
|
|
|
skins = {}
|
2017-06-15 18:19:47 +02:00
|
|
|
skins.modpath = minetest.get_modpath(minetest.get_current_modname())
|
2017-07-24 17:39:16 +02:00
|
|
|
skins.default = "character"
|
2014-03-17 06:26:58 +01:00
|
|
|
|
2017-06-16 23:16:22 +02:00
|
|
|
dofile(skins.modpath.."/skin_meta_api.lua")
|
2017-06-16 21:40:54 +02:00
|
|
|
dofile(skins.modpath.."/api.lua")
|
2017-02-09 23:06:25 +01:00
|
|
|
dofile(skins.modpath.."/skinlist.lua")
|
2018-02-13 22:31:44 +01:00
|
|
|
dofile(skins.modpath.."/formspecs.lua")
|
2018-02-13 22:02:22 +01:00
|
|
|
dofile(skins.modpath.."/chatcommands.lua")
|
2017-02-09 23:06:25 +01:00
|
|
|
-- Unified inventory page/integration
|
|
|
|
if minetest.get_modpath("unified_inventory") then
|
|
|
|
dofile(skins.modpath.."/unified_inventory_page.lua")
|
2014-03-17 06:26:58 +01:00
|
|
|
end
|
|
|
|
|
2017-06-15 17:18:51 +02:00
|
|
|
if minetest.get_modpath("sfinv") then
|
|
|
|
dofile(skins.modpath.."/sfinv_page.lua")
|
|
|
|
end
|
2017-06-16 23:00:36 +02:00
|
|
|
|
2019-06-06 21:47:49 +02:00
|
|
|
-- ie.loadfile does not exist?
|
2019-06-10 21:28:35 +02:00
|
|
|
skins.ie = minetest.request_insecure_environment()
|
2019-06-06 21:47:49 +02:00
|
|
|
skins.http = minetest.request_http_api()
|
|
|
|
dofile(skins.modpath.."/skins_updater.lua")
|
|
|
|
skins.ie = nil
|
2019-06-10 21:28:35 +02:00
|
|
|
skins.http = nil
|
2019-06-06 21:47:49 +02:00
|
|
|
|
2017-06-16 23:00:36 +02:00
|
|
|
-- 3d_armor compatibility
|
|
|
|
if minetest.global_exists("armor") then
|
2018-05-13 00:37:19 +02:00
|
|
|
skins.armor_loaded = true
|
2017-06-16 23:00:36 +02:00
|
|
|
armor.get_player_skin = function(self, name)
|
|
|
|
local skin = skins.get_player_skin(minetest.get_player_by_name(name))
|
2017-06-18 23:15:58 +02:00
|
|
|
return skin:get_texture()
|
2017-06-16 23:00:36 +02:00
|
|
|
end
|
|
|
|
armor.get_preview = function(self, name)
|
|
|
|
local skin = skins.get_player_skin(minetest.get_player_by_name(name))
|
2017-06-16 23:16:22 +02:00
|
|
|
return skin:get_preview()
|
2017-06-16 23:00:36 +02:00
|
|
|
end
|
2018-04-15 01:09:38 +02:00
|
|
|
armor.update_player_visuals = function(self, player)
|
|
|
|
if not player then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local skin = skins.get_player_skin(player)
|
|
|
|
skin:apply_skin_to_player(player)
|
|
|
|
armor:run_callbacks("on_update", player)
|
|
|
|
end
|
2017-06-16 23:00:36 +02:00
|
|
|
end
|
2017-06-18 23:15:58 +02:00
|
|
|
|
2018-06-21 08:22:54 +02:00
|
|
|
if minetest.global_exists("clothing") and clothing.player_textures then
|
|
|
|
skins.clothing_loaded = true
|
|
|
|
clothing:register_on_update(skins.update_player_skin)
|
|
|
|
end
|
|
|
|
|
2017-06-18 23:15:58 +02:00
|
|
|
-- Update skin on join
|
2018-02-14 02:19:15 +01:00
|
|
|
skins.ui_context = {}
|
2017-06-18 23:15:58 +02:00
|
|
|
minetest.register_on_joinplayer(function(player)
|
|
|
|
skins.update_player_skin(player)
|
2018-02-14 02:19:15 +01:00
|
|
|
end)
|
|
|
|
|
|
|
|
minetest.register_on_leaveplayer(function(player)
|
|
|
|
skins.ui_context[player:get_player_name()] = nil
|
2017-06-18 23:15:58 +02:00
|
|
|
end)
|
2018-04-15 01:09:38 +02:00
|
|
|
|
2020-01-08 08:07:20 +01:00
|
|
|
player_api.register_model("skinsdb_3d_armor_character_5.b3d", {
|
|
|
|
animation_speed = 30,
|
|
|
|
textures = {
|
|
|
|
"blank.png",
|
|
|
|
"blank.png",
|
|
|
|
"blank.png",
|
|
|
|
"blank.png"
|
|
|
|
},
|
|
|
|
animations = {
|
|
|
|
stand = {x=0, y=79},
|
|
|
|
lay = {x=162, y=166},
|
|
|
|
walk = {x=168, y=187},
|
|
|
|
mine = {x=189, y=198},
|
|
|
|
walk_mine = {x=200, y=219},
|
|
|
|
sit = {x=81, y=160},
|
|
|
|
},
|
|
|
|
})
|
2019-04-03 02:18:17 +02:00
|
|
|
|
|
|
|
-- Register default character.png if not part of this mod
|
|
|
|
local default_skin_obj = skins.get(skins.default)
|
|
|
|
if not default_skin_obj then
|
|
|
|
default_skin_obj = skins.new(skins.default)
|
|
|
|
default_skin_obj:set_texture("character.png")
|
|
|
|
default_skin_obj:set_meta("format", '1.0')
|
|
|
|
default_skin_obj:set_meta("_sort_id", 0)
|
|
|
|
default_skin_obj:set_meta("name", "Sam")
|
2022-02-15 18:57:14 +01:00
|
|
|
default_skin_obj:set_hand_from_texture()
|
2019-04-03 02:18:17 +02:00
|
|
|
end
|