skinsdb/init.lua

63 lines
1.5 KiB
Lua
Raw Normal View History

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
-- License: GPLv3
-- Boilerplate to support localized strings if intllib mod is installed.
skins = {}
skins.modpath = minetest.get_modpath("skins")
skins.file = minetest.get_worldpath().."skins.mt"
skins.default = "character_1"
skins.pages = {}
skins.skins = {}
skins.file_save = false
2014-03-17 06:26:58 +01:00
skins.type = { SPRITE=0, MODEL=1, ERROR=99 }
skins.get_type = function(texture)
if not skins.is_skin(texture) then
return skins.type.ERROR
2014-07-23 19:06:46 +02:00
end
return skins.type.MODEL
2014-07-23 19:06:46 +02:00
end
skins.is_skin = function(texture)
2014-07-23 13:46:42 +02:00
if not texture then
return false
2014-03-17 06:26:58 +01:00
end
if not skins.meta[texture] then
2014-07-23 13:46:42 +02:00
return false
2014-03-17 06:26:58 +01:00
end
2014-07-23 13:46:42 +02:00
return true
2014-03-17 06:26:58 +01:00
end
dofile(skins.modpath.."/skinlist.lua")
dofile(skins.modpath.."/players.lua")
2014-03-17 06:26:58 +01:00
2015-04-11 15:27:41 +02:00
skins.update_player_skin = function(player)
2014-07-23 13:46:42 +02:00
local name = player:get_player_name()
if not skins.is_skin(skins.skins[name]) then
skins.skins[name] = skins.default
2014-03-17 06:26:58 +01:00
end
2014-07-23 13:46:42 +02:00
player:set_properties({
textures = {skins.skins[name]..".png"},
2014-07-23 13:46:42 +02:00
})
2014-03-17 06:26:58 +01:00
end
-- 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
2014-07-23 13:46:42 +02:00
-- Change skin on join - reset if invalid
2014-03-17 06:26:58 +01:00
minetest.register_on_joinplayer(function(player)
2014-07-23 13:46:42 +02:00
local player_name = player:get_player_name()
if not skins.is_skin(skins.skins[player_name]) then
skins.skins[player_name] = skins.default
2014-03-17 06:26:58 +01:00
end
skins.update_player_skin(player)
2014-03-17 06:26:58 +01:00
end)