forked from Sokomine/yl_speak_up
add_new_option can add a fitting dialog result now upon creation
This commit is contained in:
parent
b2cddab50a
commit
e85c08b0d5
@ -235,7 +235,10 @@ yl_speak_up.add_new_dialog = function(dialog, pname, next_id, dialog_text)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- add a new option/answer to dialog d_id with option_text (or default "")
|
-- add a new option/answer to dialog d_id with option_text (or default "")
|
||||||
yl_speak_up.add_new_option = function(dialog, pname, next_id, d_id, option_text)
|
-- 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
|
||||||
|
-- this option/answer
|
||||||
|
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
|
||||||
end
|
end
|
||||||
@ -271,6 +274,17 @@ yl_speak_up.add_new_option = function(dialog, pname, next_id, d_id, option_text)
|
|||||||
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
|
end
|
||||||
|
|
||||||
|
-- create a fitting dialog result automaticly if possible
|
||||||
|
if(target_dialog and (dialog.n_dialogs[target_dialog] or target_dialog == "d_end")) then
|
||||||
|
local future_r_id = yl_speak_up.add_new_result(dialog, d_id, future_o_id)
|
||||||
|
-- actually store the new result
|
||||||
|
dialog.n_dialogs[d_id].d_options[future_o_id].o_results = {}
|
||||||
|
dialog.n_dialogs[d_id].d_options[future_o_id].o_results[future_r_id] = {
|
||||||
|
r_id = future_r_id,
|
||||||
|
r_type = "dialog",
|
||||||
|
r_value = target_dialog}
|
||||||
|
end
|
||||||
return future_o_id
|
return future_o_id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user