forked from Sokomine/yl_speak_up
added is_a_start_dialog for adding buttons to some dialogs
This commit is contained in:
parent
86c87b0c45
commit
06cadd9f3e
@ -110,6 +110,20 @@ yl_speak_up.edit_mode_apply_changes = function(pname, fields)
|
||||
"Dialog "..d_id..": Turned into new start dialog.")
|
||||
end
|
||||
|
||||
-- if it is *a* start dialog: buttons like give item to npc/trade/etc. will be shown
|
||||
if(fields.turn_into_a_start_dialog) then
|
||||
if(dialog.n_dialogs[ d_id ].is_a_start_dialog) then
|
||||
-- no need to waste space...
|
||||
dialog.n_dialogs[ d_id ].is_a_start_dialog = nil
|
||||
table.insert(yl_speak_up.npc_was_changed[ n_id ],
|
||||
"Dialog "..d_id..": Is no longer *a* start dialog (regarding buttons).")
|
||||
else
|
||||
dialog.n_dialogs[ d_id ].is_a_start_dialog = true
|
||||
table.insert(yl_speak_up.npc_was_changed[ n_id ],
|
||||
"Dialog "..d_id..": Turned into *a* start dialog (regarding buttons).")
|
||||
end
|
||||
end
|
||||
|
||||
-- detect changes to d_text: text of the dialog (what the npc is saying)
|
||||
-- (only happens in dialog edit menu)
|
||||
if(fields.d_text and dialog.n_dialogs[ d_id ].d_text ~= fields.d_text) then
|
||||
|
@ -621,8 +621,14 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec
|
||||
end
|
||||
end
|
||||
|
||||
-- with automatic selection from the start dialog, it is possible that the
|
||||
-- real start dialog is never shown; thus, add those buttons which need to
|
||||
-- be shown just once to all dialogs with is_a_start_dialog set
|
||||
local is_a_start_dialog = (active_dialog and active_dialog.d_sort
|
||||
and (tonumber(active_dialog.d_sort) == 0
|
||||
or active_dialog.is_a_start_dialog))
|
||||
-- add a "I want to give you something" button to the first dialog if the NPC accepts items
|
||||
if(active_dialog and active_dialog.d_sort and tonumber(active_dialog.d_sort) == 0) then
|
||||
if(is_a_start_dialog) then
|
||||
local offer_item_add_text = ""
|
||||
if(edit_mode) then
|
||||
offer_item_add_text = minetest.formspec_escape("[dialog d_got_item] -> ")
|
||||
@ -681,6 +687,22 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec
|
||||
-- (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)
|
||||
|
||||
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
|
||||
"show_inventory",
|
||||
"Access and manage the inventory of the NPC. This is used for adding trade "..
|
||||
@ -736,8 +758,7 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec
|
||||
end
|
||||
|
||||
-- add a Let's trade button to the first dialog if the NPC has trades
|
||||
if(active_dialog and active_dialog.d_sort and tonumber(active_dialog.d_sort) == 0
|
||||
and dialog.trades) then
|
||||
if(is_a_start_dialog and dialog.trades) then
|
||||
local has_trades = nil
|
||||
for k, v in pairs(dialog.trades) do
|
||||
-- has the NPC any *public* trades that are not effects/results?
|
||||
|
Loading…
Reference in New Issue
Block a user