5.x update
This commit is contained in:
parent
125ed4fd75
commit
55c0cd1dae
36
init.lua
36
init.lua
@ -1,23 +1,13 @@
|
||||
|
||||
-- Simple Skins mod for minetest
|
||||
-- Adds a simple skin selector to the inventory by using
|
||||
-- the default sfinv or inventory_plus when running.
|
||||
-- Adds a simple skin selector to the inventory.
|
||||
-- Released by TenPlus1 and based on Zeg9's code under MIT license
|
||||
|
||||
-- Load support for translation.
|
||||
local S
|
||||
|
||||
if minetest.get_translator ~= nil then
|
||||
S = minetest.get_translator("simple_skins")
|
||||
else -- boilerplate function
|
||||
S = function(str, ...)
|
||||
local args = {...}
|
||||
return str:gsub("@%d", function(match)
|
||||
return args[tonumber(match:sub(2))]
|
||||
end)
|
||||
end
|
||||
end
|
||||
local S = minetest.get_translator("simple_skins")
|
||||
|
||||
-- global and settings
|
||||
|
||||
skins = {
|
||||
skins = {}, list = {}, meta = {}, formspec = {},
|
||||
@ -30,12 +20,11 @@ skins = {
|
||||
id = 1,
|
||||
file = minetest.get_worldpath() .. "/simple_skins.mt",
|
||||
preview = minetest.settings:get_bool("simple_skins_preview"),
|
||||
translate = S,
|
||||
skin_limit = tonumber(minetest.settings:get("simple_skins_limit")) or 300
|
||||
}
|
||||
|
||||
|
||||
-- check and use specific inventory
|
||||
|
||||
if skins.unified_inventory then
|
||||
skins.transparant_list = true
|
||||
dofile(skins.modpath .. "/unified_inventory.lua")
|
||||
@ -49,8 +38,8 @@ elseif skins.sfinv then
|
||||
dofile(skins.modpath .. "/sfinv.lua")
|
||||
end
|
||||
|
||||
|
||||
-- load skin list and metadata
|
||||
|
||||
local f, data, skin = 1
|
||||
|
||||
while skins.id <= skins.skin_limit do
|
||||
@ -88,8 +77,8 @@ while skins.id <= skins.skin_limit do
|
||||
skins.id = skins.id + 1
|
||||
end
|
||||
|
||||
|
||||
-- load player skins file for backwards compatibility
|
||||
|
||||
local input = io.open(skins.file, "r")
|
||||
local data = nil
|
||||
|
||||
@ -108,12 +97,12 @@ if data and data ~= "" then
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- check for minetest 5.4 compatibility
|
||||
|
||||
local is_54 = minetest.has_feature("direct_velocity_on_players")
|
||||
|
||||
|
||||
-- create formspec for skin selection page
|
||||
|
||||
skins.formspec.main = function(name)
|
||||
|
||||
local formspec = "label[.5,2;" .. S("Select Player Skin:") .. "]"
|
||||
@ -163,8 +152,8 @@ skins.formspec.main = function(name)
|
||||
return formspec
|
||||
end
|
||||
|
||||
|
||||
-- Read the image size from a PNG file. (returns width, height)
|
||||
|
||||
local PNG_HDR = string.char(0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A)
|
||||
local function read_image_size(filename)
|
||||
|
||||
@ -187,8 +176,8 @@ local function read_image_size(filename)
|
||||
return ws:byte(), hs:byte()
|
||||
end
|
||||
|
||||
|
||||
-- update player skin
|
||||
|
||||
skins.update_player_skin = function(player)
|
||||
|
||||
if not player then
|
||||
@ -204,6 +193,7 @@ skins.update_player_skin = function(player)
|
||||
end
|
||||
end
|
||||
|
||||
-- selection event
|
||||
|
||||
skins.event_CHG = function(event, player)
|
||||
|
||||
@ -223,8 +213,8 @@ skins.event_CHG = function(event, player)
|
||||
meta:set_string("simple_skins:skin", skins.skins[name])
|
||||
end
|
||||
|
||||
|
||||
-- load player skin on join
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
|
||||
local name = player:get_player_name() ; if not name then return end
|
||||
@ -243,8 +233,8 @@ minetest.register_on_joinplayer(function(player)
|
||||
skins.update_player_skin(player)
|
||||
end)
|
||||
|
||||
|
||||
-- admin command to set player skin (usually for custom skins)
|
||||
|
||||
minetest.register_chatcommand("setskin", {
|
||||
params = "<player> <skin number>",
|
||||
description = S("Admin command to set player skin"),
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
local S = skins.translate
|
||||
local S = minetest.get_translator("simple_skins")
|
||||
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
|
3
mod.conf
3
mod.conf
@ -1,4 +1,5 @@
|
||||
name = simple_skins
|
||||
description = Adds a simple list of available skins for players to use.
|
||||
depends = default
|
||||
optional_depends = player_api, sfinv, inventory_plus, unified_inventory
|
||||
description = Mod that allows players to set their individual skins.
|
||||
min_minetest_version = 5.0
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
local S = skins.translate
|
||||
local S = minetest.get_translator("simple_skins")
|
||||
|
||||
|
||||
if skins.default_skin_tab then
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
local S = skins.translate
|
||||
local S = minetest.get_translator("simple_skins")
|
||||
|
||||
|
||||
unified_inventory.register_button("skins", {
|
||||
|
Loading…
x
Reference in New Issue
Block a user