allow to edit name, description and owner even without editor installed

This commit is contained in:
Sokomine 2024-02-12 02:10:46 +01:00
parent c1deea695c
commit b93186d3c2
3 changed files with 35 additions and 0 deletions

View File

@ -300,6 +300,7 @@ yl_speak_up.show_fs_decorated = function(pname, npc_text_already_printed, h,
"delete_this_empty_dialog,show_what_points_to_this_dialog,"..
"make_first_option,turn_into_a_start_dialog,mute_npc,"..
"un_mute_npc,button_end_edit_mode,show_inventory,order_follow,"..
"button_edit_basics,"..
"order_stand,order_wander,order_custom;"..
"bgcolor=#FF4444;textcolor=white]")
-- table.insert(formspec, "background[-1,-1;22,25;yl_speak_up_bg_dialog2.png;false]")

View File

@ -1,4 +1,12 @@
-- we have a better version of this in the editor - so not offer this particular entry:
yl_speak_up.get_fs_talkdialog_add_basic_edit = function(
pname, formspec, h, pname_for_old_fs, is_a_start_dialog,
active_dialog, luaentity, may_edit_npc, anz_options)
return {h = h, formspec = formspec}
end
-- This is the main talkdialog the NPC shows when right-clicked. (now in edit_mode)
local old_input_talk = yl_speak_up.input_talk
yl_speak_up.input_talk = function(player, formname, fields)

View File

@ -99,6 +99,13 @@ yl_speak_up.input_talk = function(player, formname, fields)
return
end
-- allow some basic editing (name, description, owner) even without editor mod installed:
if(fields.button_edit_basics) then
yl_speak_up.show_fs(player, "initial_config",
{n_id = n_id, d_id = d_id, false})
return
end
if fields.button_up then
yl_speak_up.speak_to[pname].option_index =
@ -228,6 +235,21 @@ yl_speak_up.get_fs_talkdialog_line = function(
end
-- at least allow editing name, description and owner - even without the editor mod installed
yl_speak_up.get_fs_talkdialog_add_basic_edit = function(
pname, formspec, h, pname_for_old_fs, is_a_start_dialog,
active_dialog, luaentity, may_edit_npc, anz_options)
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
"button_edit_basics",
"Edit name, description and owner of your NPC.\n"..
"For more editing, install npc_talk_edit!",
-- chat option: "[Edit name, description and owner.]"
minetest.formspec_escape("[Edit name, description and owner.]"),
true, nil, false, pname_for_old_fs) -- *not* an exit button
return {h = h, formspec = formspec}
end
-- helper function for yl_speak_up.get_fs_talkdialog:
-- if the player can edit the NPC,
-- either add a button for entering edit mode
@ -285,6 +307,10 @@ yl_speak_up.get_fs_talkdialog_add_edit_and_command_buttons = function(
minetest.formspec_escape(m.text_if_true),
(m.condition), nil, nil, pname_for_old_fs)
end
local res = yl_speak_up.get_fs_talkdialog_add_basic_edit(
pname, formspec, h, pname_for_old_fs, is_a_start_dialog,
active_dialog, luaentity, may_edit_npc, anz_options)
h = res.h
return {h = h, formspec = formspec}
end