removed obsolete functions

This commit is contained in:
Sokomine 2022-07-22 23:54:59 +02:00
parent 8dfe86802b
commit afe92d9e17

View File

@ -139,220 +139,6 @@ yl_speak_up.mesh_update_textures = function(pname, textures)
end
local function set_textures(obj, textures) -- this function takes the base name of the textures, converts them to usable textures and stores those on the NPC
local skins = textures2skin(textures)
local ent = obj:get_luaentity()
ent.yl_speak_up.skin = skins
obj:set_properties({textures = skins})
end
local function get_npc_skins(skin)
local retstring = "yl_speak_up_main_default.png"
local rettable = {"yl_speak_up_main_default.png"}
local temp = {}
-- get the files out of modpath
local mp_list = minetest.get_dir_list(yl_speak_up.modpath .. DIR_DELIM .. "textures", false)
-- get the files out of worlddir
local wp_list =
minetest.get_dir_list(
yl_speak_up.worldpath .. DIR_DELIM .. "worldmods" .. DIR_DELIM .. "yl_npc" .. DIR_DELIM .. "textures",
false
)
-- Let's join both lists.
table.insert_all(temp, mp_list)
table.insert_all(temp, wp_list)
--[[ Let's see if the files are the ones we want. Format is
yl_npc_main_name.png <-- Those are the ones we want
yl_npc_cape_name.png
yl_npc_item_name.png
]]--
local index = 1
local retindex = 1
for _, v in pairs(temp) do
local s = string.split(v, "_")
if s[1] == "yl" and s[2] == "npc" and s[3] == "main" then
index = index + 1
retstring = retstring .. "," .. v
table.insert(rettable, v)
if v == skin then
retindex = index
end
end
end
return rettable, retstring, retindex
end
local function get_npc_capes(cape)
local retstring = "yl_npc_cape_default.png"
local rettable = {"yl_npc_cape_default.png"}
local temp = {}
-- get the files out of modpath
local mp_list = minetest.get_dir_list(yl_speak_up.modpath .. DIR_DELIM .. "textures", false)
-- get the files out of worlddir
local wp_list =
minetest.get_dir_list(
yl_speak_up.worldpath .. DIR_DELIM .. "worldmods" .. DIR_DELIM .. "yl_npc" .. DIR_DELIM .. "textures",
false
)
-- Let's join both lists.
table.insert_all(temp, mp_list)
table.insert_all(temp, wp_list)
--[[ Let's see if the files are the ones we want. Format is
yl_npc_main_name.png
yl_npc_cape_name.png <-- Those are the ones we want
yl_npc_item_name.png
]]--
local index = 1
local retindex = 1
for _, v in pairs(temp) do
local s = string.split(v, "_")
if s[1] == "yl" and s[2] == "npc" and s[3] == "cape" then
index = index + 1
retstring = retstring .. "," .. v
table.insert(rettable, v)
if cape ~= "" and v == cape then
retindex = index
end
end
end
return rettable, retstring, retindex
end
-- TODO: this function is now kind of obsolete
local function create_preview(main_skin)
if main_skin == nil or main_skin == "" then
main_skin = "default_greyscale.png"
end
local player_skin = "(" .. main_skin .. ")"
local skin = ""
-- Consistent on both sizes:
--Chest
skin = skin .. "([combine:16x32:-16,-12=" .. player_skin .. "^[mask:yl_speak_up_mask_chest.png)^"
--Head
skin = skin .. "([combine:16x32:-4,-8=" .. player_skin .. "^[mask:yl_speak_up_mask_head.png)^"
--Hat
skin = skin .. "([combine:16x32:-36,-8=" .. player_skin .. "^[mask:yl_speak_up_mask_head.png)^"
--Right Arm
skin = skin .. "([combine:16x32:-44,-12=" .. player_skin .. "^[mask:yl_speak_up_mask_rarm.png)^"
--Right Leg
skin = skin .. "([combine:16x32:0,0=" .. player_skin .. "^[mask:yl_speak_up_mask_rleg.png)^"
-- Left Arm
skin = skin .. "([combine:16x32:-24,-44=" .. player_skin .. "^[mask:(yl_speak_up_mask_rarm.png^[transformFX))^"
--Left Leg
skin = skin .. "([combine:16x32:-12,-32=" .. player_skin .. "^[mask:(yl_speak_up_mask_rleg.png^[transformFX))^"
-- Add overlays for 64x skins. these wont appear if skin is 32x because it will be cropped out
--Chest Overlay
skin = skin .. "([combine:16x32:-16,-28=" .. player_skin .. "^[mask:yl_speak_up_mask_chest.png)^"
--Right Arm Overlay
skin = skin .. "([combine:16x32:-44,-28=" .. player_skin .. "^[mask:yl_speak_up_mask_rarm.png)^"
--Right Leg Overlay
skin = skin .. "([combine:16x32:0,-16=" .. player_skin .. "^[mask:yl_speak_up_mask_rleg.png)^"
--Left Arm Overlay
skin = skin .. "([combine:16x32:-40,-44=" .. player_skin .. "^[mask:(yl_speak_up_mask_rarm.png^[transformFX))^"
--Left Leg Overlay
skin = skin .. "([combine:16x32:4,-32=" .. player_skin .. "^[mask:(yl_speak_up_mask_rleg.png^[transformFX))"
-- Full Preview
skin = "(((" .. skin .. ")^[resize:64x128)^[mask:yl_speak_up_transform.png)"
return skin
end
-- TODO: link that somehow for NPC that support it
yl_speak_up.get_fs_fashion_extended_orig = function(pname)
local textures = yl_speak_up.speak_to[pname].textures
local maintable, mainlist, mainindex = get_npc_skins(textures[2])
local capetable, capelist, capeindex = get_npc_capes(textures[1])
local preview = create_preview(textures[2])
local button_cancel = "Cancel"
-- is this player editing this particular NPC? then rename the button
if( yl_speak_up.edit_mode[pname]
and yl_speak_up.edit_mode[pname] == yl_speak_up.speak_to[pname].n_id) then
button_cancel = "Back"
end
local formspec = {
"size[13.4,15]",
"dropdown[0.3,0.2;4,0.75;set_skin;",
mainlist or "",
";",
mainindex or "",
"]",
"label[4.6,0.45;",
yl_speak_up.speak_to[pname].n_id,
"]",
"label[6,0.45;",
(yl_speak_up.speak_to[pname].n_npc or "- nameless -"),
"]",
"dropdown[9.1,0.2;4,0.75;set_cape;",
capelist or "",
";",
capeindex or "",
"]",
"label[0.3,3.2;",
textures[4] or "",
"]",
"label[9.1,3.2;",
textures[3] or "",
"]",
"field_close_on_enter[set_sword;false]",
"field_close_on_enter[set_shield;false]",
"image[0.3,1;4,2;",
textures[2] or "",
"]", -- Main
"image[9.1,1;4,2;",
textures[1] or "",
"]", -- Cape
"image[0.3,4.2;4,4;",
textures[4] or "",
"]", -- Sword
"image[9.1,4.2;4,4;",
textures[3] or "",
"]", --textures[3],"]", -- Shield
"image[4.7,1;4,8;",
preview or "",
"]",
"button[0.3,8.4;3,0.75;button_cancel;"..button_cancel.."]",
"button[10.1,8.4;3,0.75;button_save;Save]",
"list[current_player;main;1.8,10;8,4;]",
-- set wielded items
"label[0.3,9.7;Wield\nleft:]",
"label[12.0,9.7;Wield\nright:]",
"list[detached:yl_speak_up_player_"..tostring(pname)..";wield;0.3,10.5;1,1;]",
"list[detached:yl_speak_up_player_"..tostring(pname)..";wield;12.0,10.5;1,1;1]",
"button[0.3,11.7;1,0.6;button_wield_left;Set]",
"button[12.0,11.7;1,0.6;button_wield_right;Set]",
"tooltip[button_wield_left;Set and store what your NPC shall wield in its left hand.]",
"tooltip[button_wield_right;Set and store what your NPC shall wield in its right hand.]",
}
return table.concat(formspec, "")
end
yl_speak_up.get_fs_fashion_extended = function(pname)
-- which texture from the textures list are we talking about?
-- this depends on the model!
@ -389,8 +175,6 @@ yl_speak_up.get_fs_fashion_extended = function(pname)
end
local preview = yl_speak_up.skin_preview_3d(mesh, tmp_textures, "4.7,0.5;5,10", nil)
-- local preview = create_preview(textures[2])
local button_cancel = "Cancel"
-- is this player editing this particular NPC? then rename the button
if( yl_speak_up.edit_mode[pname]
@ -608,16 +392,14 @@ yl_speak_up.input_fashion_extended = function(player, formname, fields)
-- only change cape if there really is a diffrent one selected
elseif(fields.set_cape and fields.set_cape ~= textures[1]) then
local mob_type = yl_speak_up.get_mob_type(pname)
local capes = yl_speak_up.mob_capes[mob_type] or {}
-- only set the cape if it is part of the list of allowed capes
local capetable, capelist, capeindex = get_npc_capes(textures[1])
for _, v in pairs(capetable) do
if(v == fields.set_cape) then
textures[1] = fields.set_cape
yl_speak_up.log_change(pname, n_id,
"(fashion) cape changed to "..tostring(fields.set_cape)..".")
-- we have found it
break
end
if(table.indexof(capes, fields.set_cape) ~= -1) then
textures[1] = fields.set_cape
yl_speak_up.log_change(pname, n_id,
"(fashion) cape changed to "..tostring(fields.set_cape)..".")
end
end