mirror of
https://github.com/APercy/airutils.git
synced 2025-03-15 08:01:22 +00:00
added a basic skin manager for pilot uniform
This commit is contained in:
parent
3575ea26ad
commit
b2c206643f
6 changed files with 102 additions and 0 deletions
3
init.lua
3
init.lua
|
@ -27,6 +27,9 @@ dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "airutils_papi.lua")
|
|||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "airutils_tug.lua")
|
||||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "airutils_repair.lua")
|
||||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "inventory_management.lua")
|
||||
if player_api then
|
||||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "pilot_skin_manager.lua")
|
||||
end
|
||||
|
||||
function airutils.remove(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
|
|
1
mod.conf
1
mod.conf
|
@ -2,3 +2,4 @@ name = airutils
|
|||
title=AirUtils
|
||||
description=A lib for airplanes and some useful tools
|
||||
author=apercy
|
||||
optional_depends=player_api
|
||||
|
|
98
pilot_skin_manager.lua
Normal file
98
pilot_skin_manager.lua
Normal file
|
@ -0,0 +1,98 @@
|
|||
|
||||
airutils.pilot_textures = {"pilot_clothes1.png","pilot_clothes2.png",}
|
||||
|
||||
minetest.register_chatcommand("au_uniform", {
|
||||
func = function(name, param)
|
||||
if minetest.check_player_privs(name, {server=true}) then
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player then
|
||||
airutils.uniform_formspec(name)
|
||||
else
|
||||
minetest.chat_send_player(name, "Something isn't working...")
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local set_player_textures =
|
||||
minetest.get_modpath("player_api") and player_api.set_textures
|
||||
or default.player_set_textures
|
||||
|
||||
function airutils.set_player_skin(player, skin)
|
||||
local backup = "airutils:bcp_last_skin"
|
||||
local player_proterties = player:get_properties()
|
||||
local texture = player_proterties.textures
|
||||
local name = player:get_player_name()
|
||||
if texture then
|
||||
if skin then
|
||||
texture = texture[1]
|
||||
if player:get_attribute(backup) == nil or player:get_attribute(backup) == "" then
|
||||
player:set_attribute(backup, texture) --texture backup
|
||||
--minetest.chat_send_all(dump(player:get_attribute(backup)))
|
||||
end
|
||||
texture = texture.."^"..skin
|
||||
if texture ~= nil and texture ~= "" then
|
||||
set_player_textures(player, { texture })
|
||||
end
|
||||
else
|
||||
local old_texture = player:get_attribute(backup)
|
||||
if set_skin then
|
||||
if player:get_attribute("set_skin:player_skin") ~= nil then
|
||||
old_texture = player:get_attribute("set_skin:player_skin")
|
||||
end
|
||||
elseif skins then
|
||||
if skins.skins[name] ~= nil then
|
||||
old_texture = skins.skins[name]
|
||||
end
|
||||
elseif u_skins then
|
||||
if u_skins.u_skins[name] ~= nil then
|
||||
old_texture = u_skins.u_skins[name]
|
||||
end
|
||||
elseif wardrobe then
|
||||
if wardrobe.playerSkins then
|
||||
if wardrobe.playerSkins[name] ~= nil then
|
||||
old_texture = wardrobe.playerSkins[name]
|
||||
end
|
||||
end
|
||||
end
|
||||
--minetest.chat_send_all(dump(old_texture))
|
||||
if old_texture ~= nil and old_texture ~= "" then
|
||||
set_player_textures(player, { old_texture })
|
||||
end
|
||||
player:set_attribute(backup, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function airutils.uniform_formspec(name)
|
||||
local basic_form = table.concat({
|
||||
"formspec_version[5]",
|
||||
"size[5,2.9]",
|
||||
}, "")
|
||||
|
||||
--minetest.chat_send_all(dump(airutils.pilot_textures))
|
||||
|
||||
local textures = ""
|
||||
if airutils.pilot_textures then
|
||||
for k, v in pairs( airutils.pilot_textures ) do
|
||||
textures = textures .. v .. ","
|
||||
end
|
||||
|
||||
basic_form = basic_form.."dropdown[0.5,0.5;4,0.8;textures;".. textures ..";0;false]"
|
||||
basic_form = basic_form.."button[0.5,1.6;4,0.8;set_texture;Set Player Texture]"
|
||||
|
||||
minetest.show_formspec(name, "airutils:change", basic_form)
|
||||
else
|
||||
minetest.chat_send_player(name, "The isn't activated as secure. Aborting")
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname == "airutils:change" then
|
||||
local name = player:get_player_name()
|
||||
if fields.textures or fields.set_texture then
|
||||
airutils.set_player_skin(player, fields.textures)
|
||||
end
|
||||
minetest.close_formspec(name, "airutils:change")
|
||||
end
|
||||
end)
|
BIN
textures/pilot_clothes1.png
Executable file
BIN
textures/pilot_clothes1.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 9 KiB |
BIN
textures/pilot_clothes2.png
Executable file
BIN
textures/pilot_clothes2.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 8.7 KiB |
BIN
textures/pilot_phones.png
Executable file
BIN
textures/pilot_phones.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
Loading…
Add table
Reference in a new issue