forked from Sokomine/yl_speak_up
find_next_id is no longer local
This commit is contained in:
parent
850343a30d
commit
a482f8664c
@ -108,7 +108,7 @@ local function get_error_message()
|
|||||||
return table.concat(formspec, "")
|
return table.concat(formspec, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function find_next_id(t)
|
yl_speak_up.find_next_id = function(t)
|
||||||
local start_id = 1
|
local start_id = 1
|
||||||
|
|
||||||
if t == nil then
|
if t == nil then
|
||||||
@ -194,7 +194,7 @@ yl_speak_up.fields_to_dialog = function(pname, fields)
|
|||||||
if fields.d_text ~= "" then -- If there is dialog text, then save new or old dialog
|
if fields.d_text ~= "" then -- If there is dialog text, then save new or old dialog
|
||||||
if fields.d_id == yl_speak_up.text_new_dialog_id then --New dialog --
|
if fields.d_id == yl_speak_up.text_new_dialog_id then --New dialog --
|
||||||
-- Find highest d_id and increase by 1
|
-- Find highest d_id and increase by 1
|
||||||
save_d_id = "d_" .. find_next_id(dialog.n_dialogs)
|
save_d_id = "d_" .. yl_speak_up.find_next_id(dialog.n_dialogs)
|
||||||
|
|
||||||
-- Initialize empty dialog
|
-- Initialize empty dialog
|
||||||
dialog.n_dialogs[save_d_id] = {}
|
dialog.n_dialogs[save_d_id] = {}
|
||||||
@ -239,7 +239,7 @@ local function options_to_dialog(pname)
|
|||||||
if yl_speak_up.speak_to[pname].o_id ~= nil and yl_speak_up.speak_to[pname].o_id ~= yl_speak_up.text_new_option_id then
|
if yl_speak_up.speak_to[pname].o_id ~= nil and yl_speak_up.speak_to[pname].o_id ~= yl_speak_up.text_new_option_id then
|
||||||
future_o_id = yl_speak_up.speak_to[pname].o_id
|
future_o_id = yl_speak_up.speak_to[pname].o_id
|
||||||
else
|
else
|
||||||
future_o_id = "o_" .. find_next_id(dialog.n_dialogs[d_id].d_options)
|
future_o_id = "o_" .. yl_speak_up.find_next_id(dialog.n_dialogs[d_id].d_options)
|
||||||
|
|
||||||
if dialog.n_dialogs[d_id].d_options == nil then
|
if dialog.n_dialogs[d_id].d_options == nil then
|
||||||
dialog.n_dialogs[d_id].d_options = {}
|
dialog.n_dialogs[d_id].d_options = {}
|
||||||
@ -256,7 +256,7 @@ local function options_to_dialog(pname)
|
|||||||
then
|
then
|
||||||
future_p_id = yl_speak_up.speak_to[pname].p_id
|
future_p_id = yl_speak_up.speak_to[pname].p_id
|
||||||
else
|
else
|
||||||
future_p_id = "p_" .. find_next_id(dialog.n_dialogs[d_id].d_options[future_o_id].o_prerequisites)
|
future_p_id = "p_" .. yl_speak_up.find_next_id(dialog.n_dialogs[d_id].d_options[future_o_id].o_prerequisites)
|
||||||
if future_p_id == "p_1" then
|
if future_p_id == "p_1" then
|
||||||
dialog.n_dialogs[d_id].d_options[future_o_id].o_prerequisites = {}
|
dialog.n_dialogs[d_id].d_options[future_o_id].o_prerequisites = {}
|
||||||
end
|
end
|
||||||
@ -1768,7 +1768,7 @@ end
|
|||||||
-- be reset to empty state (wasn't stored before)
|
-- be reset to empty state (wasn't stored before)
|
||||||
yl_speak_up.add_new_dialog = function(dialog, pname, next_id)
|
yl_speak_up.add_new_dialog = function(dialog, pname, next_id)
|
||||||
if(not(next_id)) then
|
if(not(next_id)) then
|
||||||
next_id = find_next_id(dialog.n_dialogs)
|
next_id = yl_speak_up.find_next_id(dialog.n_dialogs)
|
||||||
end
|
end
|
||||||
local future_d_id = "d_" .. next_id
|
local future_d_id = "d_" .. next_id
|
||||||
-- Initialize empty dialog
|
-- Initialize empty dialog
|
||||||
@ -1793,7 +1793,7 @@ yl_speak_up.add_new_result = function(dialog, d_id, o_id)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- create a new result (first the id, then the actual result)
|
-- 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)
|
local future_r_id = "r_" .. yl_speak_up.find_next_id(dialog.n_dialogs[d_id].d_options[o_id].o_results)
|
||||||
if future_r_id == "r_1" then
|
if future_r_id == "r_1" then
|
||||||
dialog.n_dialogs[d_id].d_options[o_id].o_results = {}
|
dialog.n_dialogs[d_id].d_options[o_id].o_results = {}
|
||||||
end
|
end
|
||||||
@ -2074,7 +2074,7 @@ yl_speak_up.edit_mode_apply_changes = function(pname, fields)
|
|||||||
if(fields[ "add_option"]) then
|
if(fields[ "add_option"]) then
|
||||||
-- count the options/answers so that the limit is not exceeded
|
-- count the options/answers so that the limit is not exceeded
|
||||||
local anz_options = 0
|
local anz_options = 0
|
||||||
local future_o_id = "o_" .. find_next_id(dialog.n_dialogs[d_id].d_options)
|
local future_o_id = "o_" .. yl_speak_up.find_next_id(dialog.n_dialogs[d_id].d_options)
|
||||||
if dialog.n_dialogs[d_id].d_options == nil then
|
if dialog.n_dialogs[d_id].d_options == nil then
|
||||||
dialog.n_dialogs[d_id].d_options = {}
|
dialog.n_dialogs[d_id].d_options = {}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user