made the old fashion formspec fashion_extended for wielded items

This commit is contained in:
Sokomine 2022-07-21 00:34:46 +02:00
parent fe4eb48822
commit 42e16d0e8b
3 changed files with 25 additions and 12 deletions

View File

@ -27,7 +27,6 @@ yl_speak_up.talk_after_spawn = true
yl_speak_up.mesh_data = {}
yl_speak_up.mesh_data["error"] = {
texture_index = 1,
-- TODO: actually handle that and call the right formspec
can_show_wielded_items = false,
skin_preview = yl_speak_up.skin_preview_normal,
}
@ -65,7 +64,7 @@ yl_speak_up.mob_skins["mobs_npc:trader"] = {
-- this here uses 64 x 64 textures:
yl_speak_up.mob_skins["yl_speak_up:human"] = {
"yl_speak_up_main_default.png"}
"yl_speak_up_main_default.png", "some_skin.png", "2022_06_28_the-lonley-lumberjack-20494635.png"}

View File

@ -328,6 +328,13 @@ yl_speak_up.input_fashion = function(player, formname, fields)
local mesh = yl_speak_up.get_mesh(pname)
local texture_index = yl_speak_up.mesh_data[mesh].texture_index
-- show extra formspec with wielded item configuration and cape setup
if(fields.button_config_wielded_items
and yl_speak_up.mesh_data[mesh].can_show_wielded_items) then
yl_speak_up.show_fs(player, "fashion_extended")
return
end
-- which skins are available? this depends on mob_type
local mob_type = yl_speak_up.get_mob_type(pname)
local skins = yl_speak_up.mob_skins[mob_type]
@ -392,9 +399,9 @@ yl_speak_up.input_fashion = function(player, formname, fields)
end
-- TODO: make use of this somehow
-- set what the NPC shall wield and which cape to wear
yl_speak_up.input_fashion_extended = function(player, formname, fields)
if formname ~= "yl_speak_up:fashion" then
if formname ~= "yl_speak_up:fashion_extended" then
return
end
@ -412,14 +419,7 @@ yl_speak_up.input_fashion_extended = function(player, formname, fields)
-- catch ESC as well
if(not(fields) or (fields.quit or fields.button_cancel or fields.button_exit)) then
yl_speak_up.fashion_wield_give_items_back(player, pname)
yl_speak_up.show_fs(player, "talk", {n_id = yl_speak_up.speak_to[pname].n_id,
d_id = yl_speak_up.speak_to[pname].d_id})
return
-- normal skins for NPC - without wielded items or capes etc.
-- TODO add a back button to get back to the normal formspec
elseif(true) then
yl_speak_up.input_fashion_normal(player, formname, fields)
yl_speak_up.show_fs(player, "fashion")
return
elseif(fields.button_wield_left
@ -606,6 +606,13 @@ yl_speak_up.get_fs_fashion = function(pname)
"The NPC will wear the skin he wore before you started changing it.",
"On a second throught - Keep your old skin. It was fine.",
(skin ~= old_texture), nil, nil, nil)
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
"button_config_wielded_items",
"What shall the NPC wield, and which cape shall he wear?",
"I'll tell you what you shall wield.",
(yl_speak_up.mesh_data[mesh].can_show_wielded_items),
"You don't know how to show wielded items. Thus, we can't configure them.",
nil, nil)
return yl_speak_up.show_fs_decorated(pname, true, h,
"",
left_window,

View File

@ -22,6 +22,9 @@ minetest.register_on_player_receive_fields( function(player, formname, fields)
elseif formname == "yl_speak_up:fashion" then
yl_speak_up.input_fashion(player, formname, fields)
return true
elseif formname == "yl_speak_up:fashion_extended" then
yl_speak_up.input_fashion_extended(player, formname, fields)
return true
-- handled in fs_properties.lua
elseif formname == "yl_speak_up:properties" then
yl_speak_up.input_properties(player, formname, fields)
@ -252,6 +255,10 @@ yl_speak_up.show_fs = function(player, fs_name, param)
yl_speak_up.show_fs_ver(pname, "yl_speak_up:fashion",
yl_speak_up.get_fs_fashion(pname))
elseif(fs_name == "fashion_extended") then
yl_speak_up.show_fs_ver(pname, "yl_speak_up:fashion_extended",
yl_speak_up.get_fs_fashion_extended(pname))
elseif(fs_name == "properties") then
if(not(param)) then
param = {}