make sure all relevant tables exist inside quest step data inside quest_api.lua
This commit is contained in:
parent
6a24488ac2
commit
7d602fccf2
@ -24,16 +24,6 @@ yl_speak_up.player_is_working_on_quest = function(player)
|
||||
-- TODO: check if the player has access to that data
|
||||
t.step_data = yl_speak_up.quests[t.q_id].step_data
|
||||
t.current_step = yl_speak_up.speak_to[t.pname].quest_step
|
||||
if(t.quest_step and t.step_data[t.quest_step]) then
|
||||
local data = t.step_data[t.quest_step]
|
||||
-- make sure needed tables exist
|
||||
if(not(data.one_step_required) or type(data.one_step_required) ~= "table") then
|
||||
yl_speak_up.quests[t.q_id].step_data[t.current_step].one_step_required = {}
|
||||
end
|
||||
if(not(data.all_steps_required) or type(data.one_step_required) ~= "table") then
|
||||
yl_speak_up.quests[t.q_id].step_data[t.current_step].all_steps_required = {}
|
||||
end
|
||||
end
|
||||
-- t contains pname, q_id, quest, step_data and current_step - or error_msg
|
||||
return t
|
||||
end
|
||||
|
@ -589,6 +589,25 @@ yl_speak_up.load_quest = function(q_id)
|
||||
return
|
||||
end
|
||||
yl_speak_up.quests[q_id] = yl_speak_up.handle_json_nil_values(data)
|
||||
-- make sure all required fields exist
|
||||
local quest = yl_speak_up.quests[q_id]
|
||||
if(quest and not(quest.step_data)) then
|
||||
quest.step_data = {}
|
||||
end
|
||||
if(quest) then
|
||||
for s, d in pairs(quest.step_data) do
|
||||
if(not(d.where)) then
|
||||
quest.step_data[s].where = {}
|
||||
end
|
||||
if(not(d.one_step_required)) then
|
||||
quest.step_data[s].one_step_required = {}
|
||||
end
|
||||
if(not(d.all_steps_required)) then
|
||||
quest.step_data[s].all_steps_required = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
yl_speak_up.quests[q_id] = quest
|
||||
return yl_speak_up.quests[q_id]
|
||||
end
|
||||
|
||||
@ -879,7 +898,12 @@ yl_speak_up.quest_step_add_quest_step = function(pname, q_id, quest_step_name)
|
||||
if(not(yl_speak_up.quests[q_id].step_data[quest_step_name])) then
|
||||
yl_speak_up.quests[q_id].step_data[quest_step_name] = {
|
||||
-- where (NPCs, locations) can this quest step be set?
|
||||
where = {}}
|
||||
where = {},
|
||||
-- at least one of this quest steps has to be achieved before this one is possible
|
||||
one_step_required = {},
|
||||
-- all of these quest steps have to be achieved before this one is possible
|
||||
all_steps_required = {}
|
||||
}
|
||||
yl_speak_up.save_quest(q_id)
|
||||
end
|
||||
-- return OK even if the quest step existed already
|
||||
|
Loading…
Reference in New Issue
Block a user