forked from your-land-mirror/yl_speak_up
make sure npc/location is part of the lists
This commit is contained in:
parent
2d2afdfb26
commit
c4e5c65773
@ -299,12 +299,12 @@ yl_speak_up.input_fs_add_quest_steps = function(player, formname, fields)
|
||||
if(msg ~= "OK") then
|
||||
return show_error_fs(player, msg)
|
||||
end
|
||||
if(not(n_id)) then
|
||||
return show_error_fs(player, "NPC or location not found.")
|
||||
end
|
||||
-- store the new connection in the NPC file itself (do not load generic dialogs)
|
||||
local dialog = yl_speak_up.load_dialog(n_id, false)
|
||||
if(dialog and dialog.n_dialogs and d_id and o_id
|
||||
and dialog.n_dialogs[d_id]
|
||||
and dialog.n_dialogs[d_id].d_options
|
||||
and dialog.n_dialogs[d_id].d_options[o_id]) then
|
||||
if(yl_speak_up.check_if_dialog_has_option(dialog, d_id, o_id)) then
|
||||
-- ok - the tables exist, so we can store the connection
|
||||
dialog.n_dialogs[d_id].d_options[o_id].quest_id = quest.var_name
|
||||
dialog.n_dialogs[d_id].d_options[o_id].quest_step = work_step
|
||||
@ -316,10 +316,7 @@ yl_speak_up.input_fs_add_quest_steps = function(player, formname, fields)
|
||||
-- the player is working on the NPC - thus, the NPC may be in a modified stage
|
||||
-- that hasn't been written to disc yet, and we need to adjust this stage as well
|
||||
dialog = yl_speak_up.speak_to[pname].dialog
|
||||
if(dialog and dialog.n_dialogs and d_id and o_id
|
||||
and dialog.n_dialogs[d_id]
|
||||
and dialog.n_dialogs[d_id].d_options
|
||||
and dialog.n_dialogs[d_id].d_options[o_id]) then
|
||||
if(yl_speak_up.check_if_dialog_has_option(dialog, d_id, o_id)) then
|
||||
-- ok - the tables exist, so we can store the connection
|
||||
dialog.n_dialogs[d_id].d_options[o_id].quest_id = quest.var_name
|
||||
dialog.n_dialogs[d_id].d_options[o_id].quest_step = work_step
|
||||
@ -327,6 +324,17 @@ yl_speak_up.input_fs_add_quest_steps = function(player, formname, fields)
|
||||
else
|
||||
return show_error_fs(player, "Failed to update NPC.")
|
||||
end
|
||||
-- make sure quest.npcs or quest.locations contains this entry
|
||||
if(string.sub(n_id, 1, 2) == "n_") then
|
||||
-- only npcs that are not yet added (and we store IDs without n_ prefix)
|
||||
local id = tonumber(string.sub(n_id, 3))
|
||||
if(id and table.indexof(quest.npcs or {}, id) == -1) then
|
||||
table.insert(yl_speak_up.quests[q_id].npcs, id)
|
||||
end
|
||||
elseif(string.sub(n_id, 1, 1) == "p"
|
||||
and table.indexof(quest.locations or {}, n_id) == -1) then
|
||||
table.insert(yl_speak_up.quests[q_id].locations, n_id)
|
||||
end
|
||||
-- show the newly created or selected step
|
||||
yl_speak_up.speak_to[pname].quest_step = work_step
|
||||
return yl_speak_up.show_fs(player, "manage_quest_steps", work_step)
|
||||
|
Loading…
Reference in New Issue
Block a user