forked from your-land-mirror/yl_speak_up
moved edit buttonss into extra function in fs_talkdialog.lua
This commit is contained in:
parent
8a921180cd
commit
c92db604d2
@ -452,6 +452,119 @@ yl_speak_up.get_fs_talkdialog_line_in_edit_mode = function(
|
|||||||
end
|
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
|
||||||
|
-- or add the buttons needed to edit the dialog when in *edit mode*
|
||||||
|
yl_speak_up.get_fs_talkdialog_add_edit_buttons = function(
|
||||||
|
formspec, h, pname_for_old_fs, oid, sb_v,
|
||||||
|
active_dialog, luaentity, edit_mode, may_edit_npc, anz_options)
|
||||||
|
if(not(may_edit_npc)) then
|
||||||
|
return {h = h, formspec = formspec}
|
||||||
|
end
|
||||||
|
-- Offer to enter edit mode if the player has the npc_talk_owner priv OR is allowed to edit the NPC.
|
||||||
|
-- The npc_master priv allows to edit all NPC.
|
||||||
|
if(not(edit_mode)) then
|
||||||
|
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||||
|
"button_start_edit_mode",
|
||||||
|
"Enters edit mode. In this mode, you can edit the texts the NPC says and the "..
|
||||||
|
"answers that can be given.",
|
||||||
|
-- chat option: "I am your owner. I have new orders for you.
|
||||||
|
"I am your owner. I have new orders for you.",
|
||||||
|
true, nil, true, pname_for_old_fs) -- is button_exit
|
||||||
|
return {h = h, formspec = formspec}
|
||||||
|
end
|
||||||
|
|
||||||
|
local offset = 0.0
|
||||||
|
-- If in edit mode, add new menu entries: "add new options", "end edit mode" and what else is needed.
|
||||||
|
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||||
|
"add_option",
|
||||||
|
-- chat option: "Add a new answer/option to this dialog."
|
||||||
|
"Adds a new option to this dialog. You can delete options via the option edit menu.",
|
||||||
|
"Add a new option/answer to this dialog. You can delete options via the option "..
|
||||||
|
"edit menu.",
|
||||||
|
-- the amount of allowed options/answers has been reached
|
||||||
|
(anz_options < yl_speak_up.max_number_of_options_per_dialog),
|
||||||
|
"Maximum number of allowed answers/options reached. No further options/answers "..
|
||||||
|
"can be added.", nil, pname_for_old_fs)
|
||||||
|
|
||||||
|
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||||
|
"delete_this_empty_dialog",
|
||||||
|
-- chat option: "Delete this dialog."
|
||||||
|
"Dialogs can only be deleted when they are empty and have no more "..
|
||||||
|
"options/answers. This is the case here, so the dialog can be deleted.",
|
||||||
|
"Delete this empty dialog.",
|
||||||
|
(active_dialog and active_dialog.d_text == "" and anz_options == 0),
|
||||||
|
-- (but only show this option if the dialog is empty)
|
||||||
|
"If you want to delete this dialog, you need to delete all options and its "..
|
||||||
|
"text first.", nil, pname_for_old_fs)
|
||||||
|
|
||||||
|
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||||
|
"show_what_points_to_this_dialog",
|
||||||
|
-- chat option: "Show what points to this dialog."
|
||||||
|
"Show which other dialog options or failed actions\n"..
|
||||||
|
"or effects lead the player to this dialog here.",
|
||||||
|
"Show what points to this dialog.",
|
||||||
|
-- there is no alternate text to show
|
||||||
|
true, nil, nil, pname_for_old_fs)
|
||||||
|
|
||||||
|
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||||
|
"make_first_option",
|
||||||
|
-- chat option: "Make this dialog the first one shown when starting to talk."
|
||||||
|
"The NPC has to start with one dialog when he is right-clicked. "..
|
||||||
|
"Make this dialog the one shown.",
|
||||||
|
"Make this dialog the first one shown when starting a conversation.",
|
||||||
|
(active_dialog and active_dialog.d_sort and tonumber(active_dialog.d_sort) ~= 0),
|
||||||
|
-- (but only show this option if it's not already the first one)
|
||||||
|
"This dialog will be shown whenever a conversation is started.", nil,pname_for_old_fs)
|
||||||
|
|
||||||
|
local b_text = "Turn this into"
|
||||||
|
if(is_a_start_dialog) then
|
||||||
|
b_text = "This shall no longer be"
|
||||||
|
end
|
||||||
|
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||||
|
"turn_into_a_start_dialog",
|
||||||
|
"With automatic selection of options, it is possible that the real\n"..
|
||||||
|
"start dialog will never be shown to the player. However, we need\n"..
|
||||||
|
"to add some buttons to that start dialog for i.e. giving items\n"..
|
||||||
|
"to the NPC and for trading. Therefore, dialogs can be marked as\n"..
|
||||||
|
"*a* start dialog so that these buttons will be added to those dialogs.",
|
||||||
|
b_text.." *a* start dialog where buttons for trade etc. are shown.",
|
||||||
|
not(active_dialog and active_dialog.d_sort and tonumber(active_dialog.d_sort) == 0),
|
||||||
|
"The start dialog automaticly counts as *a* start dialog where buttons for "..
|
||||||
|
"trade etc. are shown.", nil, pname_for_old_fs)
|
||||||
|
|
||||||
|
-- chat option: Mute/Unmute NPC
|
||||||
|
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||||
|
"mute_npc",
|
||||||
|
-- chat option: mute the NPC
|
||||||
|
"The NPC will no longer show his dialogs when he is right-clicked. This is "..
|
||||||
|
"useful while you edit the NPC and don't want players to see "..
|
||||||
|
"unfinished entries and/or quests.",
|
||||||
|
"State: Not muted. Stop talking to other players while I give you new orders.",
|
||||||
|
(luaentity and luaentity.yl_speak_up.talk), nil, nil, pname_for_old_fs)
|
||||||
|
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||||
|
"un_mute_npc",
|
||||||
|
-- unmute the NPC
|
||||||
|
"The NPC will show his dialogs to other players when he is right-clicked. "..
|
||||||
|
"This is the normal mode of operation. Choose this when you are "..
|
||||||
|
"finished editing.",
|
||||||
|
"State: You are currently muted. Talk to anyone again who wants to talk to you.",
|
||||||
|
-- the NPC has to be there
|
||||||
|
(luaentity and not(luaentity.yl_speak_up.talk)), nil, nil, pname_for_old_fs)
|
||||||
|
|
||||||
|
|
||||||
|
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||||
|
"button_end_edit_mode",
|
||||||
|
"Ends edit mode. From now on, your NPC will talk to you like he talks to other "..
|
||||||
|
"players. You can always give him new orders by entering edit mode again.",
|
||||||
|
-- chat option:"That was all. I'm finished with giving you new orders. Remember them!"
|
||||||
|
"That was all. I'm finished with giving you new orders. Remember them!",
|
||||||
|
true, nil, true, pname_for_old_fs) -- is button_exit
|
||||||
|
return {h = h, formspec = formspec}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- recursion_depth is increased each time autoanswer is automaticly selected
|
-- recursion_depth is increased each time autoanswer is automaticly selected
|
||||||
yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, recursion_depth)
|
yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, recursion_depth)
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
@ -713,104 +826,16 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec
|
|||||||
if(obj) then
|
if(obj) then
|
||||||
luaentity = obj:get_luaentity()
|
luaentity = obj:get_luaentity()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- If in edit mode, add new menu entries: "add new options", "end edit mode" and what else is needed.
|
-- If in edit mode, add new menu entries: "add new options", "end edit mode" and what else is needed.
|
||||||
if(edit_mode) then
|
-- Else allow to enter edit mode
|
||||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
local res = yl_speak_up.get_fs_talkdialog_add_edit_buttons(
|
||||||
"add_option",
|
formspec, h, pname_for_old_fs, oid, sb_v,
|
||||||
-- chat option: "Add a new answer/option to this dialog."
|
active_dialog, luaentity, edit_mode, may_edit_npc, anz_options)
|
||||||
"Adds a new option to this dialog. You can delete options via the option edit menu.",
|
formspec = res.formspec
|
||||||
"Add a new option/answer to this dialog. You can delete options via the option "..
|
h = res.h
|
||||||
"edit menu.",
|
|
||||||
-- the amount of allowed options/answers has been reached
|
|
||||||
(anz_options < yl_speak_up.max_number_of_options_per_dialog),
|
|
||||||
"Maximum number of allowed answers/options reached. No further options/answers "..
|
|
||||||
"can be added.", nil, pname_for_old_fs)
|
|
||||||
|
|
||||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
|
||||||
"delete_this_empty_dialog",
|
|
||||||
-- chat option: "Delete this dialog."
|
|
||||||
"Dialogs can only be deleted when they are empty and have no more "..
|
|
||||||
"options/answers. This is the case here, so the dialog can be deleted.",
|
|
||||||
"Delete this empty dialog.",
|
|
||||||
(active_dialog and active_dialog.d_text == "" and anz_options == 0),
|
|
||||||
-- (but only show this option if the dialog is empty)
|
|
||||||
"If you want to delete this dialog, you need to delete all options and its "..
|
|
||||||
"text first.", nil, pname_for_old_fs)
|
|
||||||
|
|
||||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
|
||||||
"show_what_points_to_this_dialog",
|
|
||||||
-- chat option: "Show what points to this dialog."
|
|
||||||
"Show which other dialog options or failed actions\n"..
|
|
||||||
"or effects lead the player to this dialog here.",
|
|
||||||
"Show what points to this dialog.",
|
|
||||||
-- there is no alternate text to show
|
|
||||||
true, nil, nil, pname_for_old_fs)
|
|
||||||
|
|
||||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
|
||||||
"make_first_option",
|
|
||||||
-- chat option: "Make this dialog the first one shown when starting to talk."
|
|
||||||
"The NPC has to start with one dialog when he is right-clicked. "..
|
|
||||||
"Make this dialog the one shown.",
|
|
||||||
"Make this dialog the first one shown when starting a conversation.",
|
|
||||||
(active_dialog and active_dialog.d_sort and tonumber(active_dialog.d_sort) ~= 0),
|
|
||||||
-- (but only show this option if it's not already the first one)
|
|
||||||
"This dialog will be shown whenever a conversation is started.", nil,pname_for_old_fs)
|
|
||||||
|
|
||||||
local b_text = "Turn this into"
|
|
||||||
if(is_a_start_dialog) then
|
|
||||||
b_text = "This shall no longer be"
|
|
||||||
end
|
|
||||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
|
||||||
"turn_into_a_start_dialog",
|
|
||||||
"With automatic selection of options, it is possible that the real\n"..
|
|
||||||
"start dialog will never be shown to the player. However, we need\n"..
|
|
||||||
"to add some buttons to that start dialog for i.e. giving items\n"..
|
|
||||||
"to the NPC and for trading. Therefore, dialogs can be marked as\n"..
|
|
||||||
"*a* start dialog so that these buttons will be added to those dialogs.",
|
|
||||||
b_text.." *a* start dialog where buttons for trade etc. are shown.",
|
|
||||||
not(active_dialog and active_dialog.d_sort and tonumber(active_dialog.d_sort) == 0),
|
|
||||||
"The start dialog automaticly counts as *a* start dialog where buttons for "..
|
|
||||||
"trade etc. are shown.", nil, pname_for_old_fs)
|
|
||||||
|
|
||||||
-- chat option: Mute/Unmute NPC
|
|
||||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
|
||||||
"mute_npc",
|
|
||||||
-- chat option: mute the NPC
|
|
||||||
"The NPC will no longer show his dialogs when he is right-clicked. This is "..
|
|
||||||
"useful while you edit the NPC and don't want players to see "..
|
|
||||||
"unfinished entries and/or quests.",
|
|
||||||
"State: Not muted. Stop talking to other players while I give you new orders.",
|
|
||||||
(luaentity and luaentity.yl_speak_up.talk), nil, nil, pname_for_old_fs)
|
|
||||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
|
||||||
"un_mute_npc",
|
|
||||||
-- unmute the NPC
|
|
||||||
"The NPC will show his dialogs to other players when he is right-clicked. "..
|
|
||||||
"This is the normal mode of operation. Choose this when you are "..
|
|
||||||
"finished editing.",
|
|
||||||
"State: You are currently muted. Talk to anyone again who wants to talk to you.",
|
|
||||||
-- the NPC has to be there
|
|
||||||
(luaentity and not(luaentity.yl_speak_up.talk)), nil, nil, pname_for_old_fs)
|
|
||||||
|
|
||||||
|
|
||||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
|
||||||
"button_end_edit_mode",
|
|
||||||
"Ends edit mode. From now on, your NPC will talk to you like he talks to other "..
|
|
||||||
"players. You can always give him new orders by entering edit mode again.",
|
|
||||||
-- chat option:"That was all. I'm finished with giving you new orders. Remember them!"
|
|
||||||
"That was all. I'm finished with giving you new orders. Remember them!",
|
|
||||||
true, nil, true, pname_for_old_fs) -- is button_exit
|
|
||||||
|
|
||||||
-- Offer to enter edit mode if the player has the npc_talk_owner priv AND owns the npc.
|
|
||||||
-- The npc_master priv allows to edit all NPC.
|
|
||||||
elseif(may_edit_npc) then
|
|
||||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
|
||||||
"button_start_edit_mode",
|
|
||||||
"Enters edit mode. In this mode, you can edit the texts the NPC says and the "..
|
|
||||||
"answers that can be given.",
|
|
||||||
-- chat option: "I am your owner. I have new orders for you.
|
|
||||||
"I am your owner. I have new orders for you.",
|
|
||||||
true, nil, true, pname_for_old_fs) -- is button_exit
|
|
||||||
end
|
|
||||||
|
|
||||||
-- add a Let's trade button to the first dialog if the NPC has trades
|
-- add a Let's trade button to the first dialog if the NPC has trades
|
||||||
if(is_a_start_dialog and dialog.trades) then
|
if(is_a_start_dialog and dialog.trades) then
|
||||||
|
Loading…
Reference in New Issue
Block a user