diff --git a/fs_manage_quest_steps.lua b/fs_manage_quest_steps.lua index ee1f6c5..2fd094d 100644 --- a/fs_manage_quest_steps.lua +++ b/fs_manage_quest_steps.lua @@ -24,6 +24,16 @@ 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 @@ -145,6 +155,25 @@ yl_speak_up.input_fs_manage_quest_steps = function(player, formname, fields) return end end + -- show prev logical step + if(fields and fields.show_prev_step) then + if(#res.step_data[res.current_step].one_step_required > 0) then + yl_speak_up.show_fs(player, "manage_quest_steps", + res.step_data[res.current_step].one_step_required[1]) + return + elseif(#res.step_data[res.current_step].all_steps_required > 0) then + yl_speak_up.show_fs(player, "manage_quest_steps", + res.step_data[res.current_step].all_steps_required[1]) + return + end + -- show next logical step + elseif(fields and fields.show_next_step) then + local list = yl_speak_up.quest_step_required_for(res.step_data, res.current_step) + if(list and #list > 0) then + yl_speak_up.show_fs(player, "manage_quest_steps", list[1]) + return + end + end end if(fields and (fields.add_to_one_needed or fields.add_to_all_needed