forked from Sokomine/yl_speak_up
added function yl_speak_up.mesh_update_textures
This commit is contained in:
parent
e062eec580
commit
8dfe86802b
@ -118,6 +118,27 @@ local function textures2skin(textures)
|
||||
return temp
|
||||
end
|
||||
|
||||
|
||||
yl_speak_up.mesh_update_textures = function(pname, textures)
|
||||
-- actually make sure that the NPC updates its texture
|
||||
local obj = yl_speak_up.speak_to[pname].obj
|
||||
if(not(obj) or not(textures)) then
|
||||
return
|
||||
end
|
||||
-- the skins with wielded items need some conversion,
|
||||
-- while simpler models may just apply the texture
|
||||
local mesh = yl_speak_up.get_mesh(pname)
|
||||
if(mesh and yl_speak_up.mesh_data[mesh].textures_to_skin) then
|
||||
textures = textures2skin(textures)
|
||||
end
|
||||
obj:set_properties({ textures = textures })
|
||||
yl_speak_up.speak_to[pname].skins = textures
|
||||
-- scrolling through the diffrent skins updates the skin; avoid spam in the log
|
||||
-- yl_speak_up.log_change(pname, n_id,
|
||||
-- "(fashion) skin changed to "..tostring(new_skin)..".")
|
||||
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)
|
||||
|
||||
@ -531,20 +552,7 @@ yl_speak_up.input_fashion = function(player, formname, fields)
|
||||
-- if there is a new skin to consider
|
||||
if(textures[texture_index] ~= new_skin) then
|
||||
textures[texture_index] = new_skin
|
||||
-- actually make sure that the NPC updates its texture
|
||||
local obj = yl_speak_up.speak_to[pname].obj
|
||||
if(obj) then
|
||||
-- the skins with wielded items need some conversion,
|
||||
-- while simpler models may just apply the texture
|
||||
local mesh = yl_speak_up.get_mesh(pname)
|
||||
if(mesh and yl_speak_up.mesh_data[mesh].textures_to_skin) then
|
||||
textures = textures2skin(textures)
|
||||
end
|
||||
obj:set_properties({ textures = textures })
|
||||
end
|
||||
-- scrolling through the diffrent skins updates the skin; avoid spam in the log
|
||||
-- yl_speak_up.log_change(pname, n_id,
|
||||
-- "(fashion) skin changed to "..tostring(new_skin)..".")
|
||||
yl_speak_up.mesh_update_textures(pname, textures)
|
||||
end
|
||||
if(fields.button_old_skin or fields.button_store_new_skin) then
|
||||
yl_speak_up.speak_to[pname].old_texture = nil
|
||||
@ -611,19 +619,11 @@ yl_speak_up.input_fashion_extended = function(player, formname, fields)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
elseif fields.button_save then
|
||||
local obj = yl_speak_up.speak_to[pname].obj
|
||||
if obj ~= nil and obj:get_luaentity() ~= nil then
|
||||
-- save textures
|
||||
yl_speak_up.speak_to[pname].skins = textures2skin(textures)
|
||||
set_textures(obj, textures)
|
||||
yl_speak_up.log_change(pname, n_id,
|
||||
"(fashion) saved changes.")
|
||||
end
|
||||
yl_speak_up.fashion_wield_give_items_back(player, pname)
|
||||
end
|
||||
if(fields.button_wield_left or fields.button_wield_right or fields.set_cape) then
|
||||
|
||||
if(fields.button_wield_left or fields.button_wield_right or fields.set_cape or fields.button_sve) then
|
||||
yl_speak_up.fashion_wield_give_items_back(player, pname)
|
||||
yl_speak_up.mesh_update_textures(pname, textures)
|
||||
yl_speak_up.show_fs(player, "fashion_extended")
|
||||
return
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user