added function yl_speak_up.add_new_result

This commit is contained in:
Sokomine 2021-05-23 13:15:27 +02:00
parent 870751aaab
commit eecdfdcc00

View File

@ -77,7 +77,7 @@ end
local function get_result_types()
--local t_grt = {"dialog", "give_item", "quest", "function", "auto", "delete"}
local t_grt = {"dialog","give_item","take_item","move","function","delete"}
local t_grt = {"dialog","give_item","take_item","move","function","trade","delete"}
local s_grt = ""
for _, v in pairs(t_grt) do
s_grt = s_grt .. v .. ","
@ -267,11 +267,7 @@ local function options_to_dialog(pname)
if yl_speak_up.speak_to[pname].r_id ~= nil and yl_speak_up.speak_to[pname].r_id ~= yl_speak_up.text_new_result_id then
future_r_id = yl_speak_up.speak_to[pname].r_id
else
future_r_id = "r_" .. find_next_id(dialog.n_dialogs[d_id].d_options[future_o_id].o_results)
if future_r_id == "r_1" then
dialog.n_dialogs[d_id].d_options[future_o_id].o_results = {}
end
dialog.n_dialogs[d_id].d_options[future_o_id].o_results[future_r_id] = {}
future_r_id = yl_speak_up.add_new_result(dialog, d_id, future_o_id)
end
--Edit options
@ -873,7 +869,7 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id)
if(has_trade) then
button_add_edit_trade = ""..
"button[14.8,10;2.0,0.9;effect_show_trade;Show trade]"..
"tooltip[effect_edit_trade;Show and edit the trade that starts "..
"tooltip[effect_show_trade;Show and edit the trade that starts "..
"when selectiong this option.]"
else
button_add_edit_trade = ""..
@ -2049,6 +2045,22 @@ yl_speak_up.add_new_dialog = function(dialog, pname, next_id)
end
-- add a new result to option o_id of dialog d_id
yl_speak_up.add_new_result = function(dialog, d_id, o_id)
if(not(dialog) or not(dialog.n_dialogs) or not(dialog.n_dialogs[d_id])
or not(dialog.n_dialogs[d_id].d_options) or not(dialog.n_dialogs[d_id].d_options[o_id])) then
return
end
-- create a new result (first the id, then the actual result)
local future_r_id = "r_" .. find_next_id(dialog.n_dialogs[d_id].d_options[o_id].o_results)
if future_r_id == "r_1" then
dialog.n_dialogs[d_id].d_options[o_id].o_results = {}
end
dialog.n_dialogs[d_id].d_options[o_id].o_results[future_r_id] = {}
return future_r_id
end
-- this is always called when switching to a new dialog; but only in edit_mode does
-- it show a formspec asking for change/back/discard
yl_speak_up.save_changes_and_switch_to_other_dialog = function(player, fields, target_dialog)
@ -2428,10 +2440,7 @@ yl_speak_up.edit_mode_apply_changes = function(pname, fields)
tostring(fields[ "d_id_"..k])..".")
-- create a new result (first the id, then the actual result)
local future_r_id = "r_" .. find_next_id(dialog.n_dialogs[d_id].d_options[k].o_results)
if future_r_id == "r_1" then
dialog.n_dialogs[d_id].d_options[k].o_results = {}
end
local future_r_id = yl_speak_up.add_new_result(dialog, d_id, k)
-- actually store the new result
dialog.n_dialogs[d_id].d_options[k].o_results[future_r_id] = {
r_id = future_r_id,