mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-06-16 21:58:05 +02:00
made functions in functions_dialog.lua only optionally dependant on pname
This commit is contained in:
parent
c4ebef21f0
commit
4cf06da1e4
@ -64,6 +64,8 @@ end
|
|||||||
-- the option to override next_id and provide a value is needed when a new dialog was
|
-- the option to override next_id and provide a value is needed when a new dialog was
|
||||||
-- added, then edited, and then discarded; it's still needed after that, but has to
|
-- added, then edited, and then discarded; it's still needed after that, but has to
|
||||||
-- be reset to empty state (wasn't stored before)
|
-- be reset to empty state (wasn't stored before)
|
||||||
|
-- Note: pname is only passed to yl_speak_up.add_new_option - which is only used if
|
||||||
|
-- dialog_text is empty (and only for logging)
|
||||||
yl_speak_up.add_new_dialog = function(dialog, pname, next_id, dialog_text)
|
yl_speak_up.add_new_dialog = function(dialog, pname, next_id, dialog_text)
|
||||||
if(not(next_id)) then
|
if(not(next_id)) then
|
||||||
next_id = yl_speak_up.find_next_id(dialog.n_dialogs)
|
next_id = yl_speak_up.find_next_id(dialog.n_dialogs)
|
||||||
@ -99,6 +101,7 @@ end
|
|||||||
-- option_text (optional) the text that shall be shown as option/answer
|
-- option_text (optional) the text that shall be shown as option/answer
|
||||||
-- target_dialog (optional) the target dialog where the player will end up when choosing
|
-- target_dialog (optional) the target dialog where the player will end up when choosing
|
||||||
-- this option/answer
|
-- this option/answer
|
||||||
|
-- Note: pname is only used for logging (and for changing o_sort)
|
||||||
yl_speak_up.add_new_option = function(dialog, pname, next_id, d_id, option_text, target_dialog)
|
yl_speak_up.add_new_option = function(dialog, pname, next_id, d_id, option_text, target_dialog)
|
||||||
if(not(dialog) or not(dialog.n_dialogs) or not(dialog.n_dialogs[d_id])) then
|
if(not(dialog) or not(dialog.n_dialogs) or not(dialog.n_dialogs[d_id])) then
|
||||||
return nil
|
return nil
|
||||||
@ -127,18 +130,25 @@ yl_speak_up.add_new_option = function(dialog, pname, next_id, d_id, option_text,
|
|||||||
o_text_when_prerequisites_not_met = "",
|
o_text_when_prerequisites_not_met = "",
|
||||||
o_text_when_prerequisites_met = (option_text or ""),
|
o_text_when_prerequisites_met = (option_text or ""),
|
||||||
}
|
}
|
||||||
-- necessary in order for it to work
|
|
||||||
local s = yl_speak_up.sanitize_sort(dialog.n_dialogs[d_id].d_options, yl_speak_up.speak_to[pname].o_sort)
|
local start_with_o_sort = nil
|
||||||
dialog.n_dialogs[d_id].d_options[future_o_id].o_sort = s
|
if(pname and pname ~= "") then
|
||||||
-- log only in edit mode
|
-- log only in edit mode
|
||||||
local n_id = yl_speak_up.speak_to[pname].n_id
|
local n_id = yl_speak_up.speak_to[pname].n_id
|
||||||
-- would be too difficult to add an exception for edit_mode here; thus, we do it directly here:
|
-- would be too difficult to add an exception for edit_mode here; thus, we do it directly here:
|
||||||
if(yl_speak_up.npc_was_changed
|
if(yl_speak_up.npc_was_changed
|
||||||
and yl_speak_up.npc_was_changed[n_id]) then
|
and yl_speak_up.npc_was_changed[n_id]) then
|
||||||
table.insert(yl_speak_up.npc_was_changed[ n_id ],
|
table.insert(yl_speak_up.npc_was_changed[ n_id ],
|
||||||
"Dialog "..d_id..": Added new option/answer "..future_o_id..".")
|
"Dialog "..d_id..": Added new option/answer "..future_o_id..".")
|
||||||
|
end
|
||||||
|
|
||||||
|
start_with_o_sort = yl_speak_up.speak_to[pname].o_sort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- necessary in order for it to work
|
||||||
|
local new_o_sort = yl_speak_up.sanitize_sort(dialog.n_dialogs[d_id].d_options, start_with_o_sort)
|
||||||
|
dialog.n_dialogs[d_id].d_options[future_o_id].o_sort = new_o_sort
|
||||||
|
|
||||||
-- letting d_got_item point back to itself is not a good idea because the
|
-- letting d_got_item point back to itself is not a good idea because the
|
||||||
-- NPC will then end up in a loop; plus the d_got_item dialog is intended for
|
-- NPC will then end up in a loop; plus the d_got_item dialog is intended for
|
||||||
-- automatic processing, not for showing to the player
|
-- automatic processing, not for showing to the player
|
||||||
|
Loading…
Reference in New Issue
Block a user