forked from your-land-mirror/yl_speak_up
quest steps are clickable from quest overview page
This commit is contained in:
parent
b621fe7b12
commit
3f9da138e0
@ -24,6 +24,11 @@ yl_speak_up.player_is_working_on_quest = function(player)
|
|||||||
-- TODO: check if the player has access to that data
|
-- TODO: check if the player has access to that data
|
||||||
t.step_data = yl_speak_up.quests[t.q_id].step_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
|
t.current_step = yl_speak_up.speak_to[t.pname].quest_step
|
||||||
|
-- check here if the step exists
|
||||||
|
if(t.current_step and not(t.step_data[t.current_step])) then
|
||||||
|
yl_speak_up.speak_to[t.pname].quest_step = nil
|
||||||
|
t.current_step = nil
|
||||||
|
end
|
||||||
-- t contains pname, q_id, quest, step_data and current_step - or error_msg
|
-- t contains pname, q_id, quest, step_data and current_step - or error_msg
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
@ -166,22 +171,21 @@ yl_speak_up.input_fs_manage_quest_steps_check_fields = function(player, formname
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- makes use of yl_speak_up.input_fs_manage_general and is thus pretty short
|
|
||||||
yl_speak_up.input_fs_manage_quest_steps = function(player, formname, fields)
|
|
||||||
-- TODO: check if the player is allowed to access that quest
|
|
||||||
local pname = player:get_player_name()
|
|
||||||
|
|
||||||
if(not(fields) or (fields and fields.back)) then
|
-- some lists are offered in diffrent formspecs for selection;
|
||||||
yl_speak_up.show_fs(player, "manage_quests")
|
-- this function will display the right quest step if possible
|
||||||
return
|
-- res needs to be yl_speak_up.player_is_working_on_quest(player)
|
||||||
|
yl_speak_up.input_routing_show_a_quest_step = function(player, formname, fields, back_field_name, res)
|
||||||
|
if(not(player) or not(fields) or (fields and fields.back) or not(res)) then
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
local res = yl_speak_up.player_is_working_on_quest(player)
|
|
||||||
if(res.error_msg) then
|
if(res.error_msg) then
|
||||||
yl_speak_up.show_fs(player, "msg", {
|
yl_speak_up.show_fs(player, "msg", {
|
||||||
input_to = formname,
|
input_to = formname,
|
||||||
formspec = yl_speak_up.get_fs_quest_edit_error(error_msg, "back_from_error_msg")
|
formspec = yl_speak_up.get_fs_quest_edit_error(error_msg, back_field_name)
|
||||||
})
|
})
|
||||||
return
|
return true
|
||||||
end
|
end
|
||||||
local step_data = res.step_data or {}
|
local step_data = res.step_data or {}
|
||||||
|
|
||||||
@ -203,24 +207,24 @@ yl_speak_up.input_fs_manage_quest_steps = function(player, formname, fields)
|
|||||||
-- selected an unconnected/unused quest step
|
-- selected an unconnected/unused quest step
|
||||||
list = yl_speak_up.quest_step_get_start_end_unconnected_lists(step_data).unconnected_steps
|
list = yl_speak_up.quest_step_get_start_end_unconnected_lists(step_data).unconnected_steps
|
||||||
field_name = "select_from_unconnected_steps"
|
field_name = "select_from_unconnected_steps"
|
||||||
elseif(res.current_step and fields.one_step_required) then
|
elseif(res.current_step and step_data[res.current_step] and fields.one_step_required) then
|
||||||
list = step_data[res.current_step].one_step_required
|
list = step_data[res.current_step].one_step_required
|
||||||
field_name = "one_step_required"
|
field_name = "one_step_required"
|
||||||
elseif(res.current_step and fields.all_steps_required) then
|
elseif(res.current_step and step_data[res.current_step] and fields.all_steps_required) then
|
||||||
list = step_data[res.current_step].all_steps_required
|
list = step_data[res.current_step].all_steps_required
|
||||||
field_name = "all_steps_required"
|
field_name = "all_steps_required"
|
||||||
elseif(res.current_step and fields.next_steps_show) then
|
elseif(res.current_step and step_data[res.current_step] and fields.next_steps_show) then
|
||||||
list = yl_speak_up.quest_step_required_for(step_data, res.current_step)
|
list = yl_speak_up.quest_step_required_for(step_data, res.current_step)
|
||||||
field_name = "next_steps_show"
|
field_name = "next_steps_show"
|
||||||
elseif(fields.add_from_available) then
|
elseif(fields.add_from_available) then
|
||||||
-- selected a quest step from the list of available steps offered
|
-- selected a quest step from the list of available steps offered
|
||||||
list = yl_speak_up.speak_to[pname].available_quest_steps or {}
|
list = yl_speak_up.speak_to[res.pname].available_quest_steps or {}
|
||||||
field_name = "add_from_available"
|
field_name = "add_from_available"
|
||||||
-- this table has a header
|
-- this table has a header
|
||||||
row_offset = 1
|
row_offset = 1
|
||||||
|
|
||||||
-- show prev logical step
|
-- show prev logical step
|
||||||
elseif(fields.show_prev_step) then
|
elseif(fields.show_prev_step and res.current_step and step_data[res.current_step]) then
|
||||||
if( #step_data[res.current_step].one_step_required > 0) then
|
if( #step_data[res.current_step].one_step_required > 0) then
|
||||||
show_step = step_data[res.current_step].one_step_required[1]
|
show_step = step_data[res.current_step].one_step_required[1]
|
||||||
elseif(#step_data[res.current_step].all_steps_required > 0) then
|
elseif(#step_data[res.current_step].all_steps_required > 0) then
|
||||||
@ -243,17 +247,34 @@ yl_speak_up.input_fs_manage_quest_steps = function(player, formname, fields)
|
|||||||
end
|
end
|
||||||
-- actually show the selected quest step
|
-- actually show the selected quest step
|
||||||
if(show_step and show_step ~= "") then
|
if(show_step and show_step ~= "") then
|
||||||
yl_speak_up.speak_to[pname].quest_step = show_step
|
yl_speak_up.speak_to[res.pname].quest_step = show_step
|
||||||
yl_speak_up.show_fs(player, "manage_quest_steps", show_step)
|
yl_speak_up.show_fs(player, "manage_quest_steps", show_step)
|
||||||
return
|
return true
|
||||||
-- show the entire list
|
-- show the entire list
|
||||||
elseif(fields.show_step_list) then
|
elseif(fields.show_step_list) then
|
||||||
yl_speak_up.speak_to[res.pname].tmp_index_general = -1
|
yl_speak_up.speak_to[res.pname].tmp_index_general = -1
|
||||||
yl_speak_up.speak_to[pname].quest_step = nil
|
yl_speak_up.speak_to[res.pname].quest_step = nil
|
||||||
yl_speak_up.show_fs(player, "manage_quest_steps", nil)
|
yl_speak_up.show_fs(player, "manage_quest_steps", nil)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- makes use of yl_speak_up.input_fs_manage_general and is thus pretty short
|
||||||
|
yl_speak_up.input_fs_manage_quest_steps = function(player, formname, fields)
|
||||||
|
local pname = player:get_player_name()
|
||||||
|
|
||||||
|
if(not(fields) or (fields and fields.back)) then
|
||||||
|
yl_speak_up.show_fs(player, "manage_quests")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local res = yl_speak_up.player_is_working_on_quest(player)
|
||||||
|
|
||||||
|
-- show a particular quest step?
|
||||||
|
if(yl_speak_up.input_routing_show_a_quest_step(player, formname, fields, "back_from_error_msg", res)) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if(res.current_step) then
|
if(res.current_step) then
|
||||||
-- forward input from that formspec...
|
-- forward input from that formspec...
|
||||||
|
|||||||
@ -49,6 +49,15 @@ yl_speak_up.input_fs_manage_quests = function(player, formname, fields)
|
|||||||
yl_speak_up.show_fs(player, "manage_quest_steps")
|
yl_speak_up.show_fs(player, "manage_quest_steps")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- show a particular quest step from the start/unconnected/end list?
|
||||||
|
local res = yl_speak_up.player_is_working_on_quest(player)
|
||||||
|
if(yl_speak_up.speak_to[pname]
|
||||||
|
and yl_speak_up.speak_to[pname].q_id
|
||||||
|
and yl_speak_up.input_routing_show_a_quest_step(player, formname, fields, "back", res)) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local quest_list = yl_speak_up.get_sorted_quest_list(pname)
|
local quest_list = yl_speak_up.get_sorted_quest_list(pname)
|
||||||
local res = yl_speak_up.input_fs_manage_general(player, formname, fields,
|
local res = yl_speak_up.input_fs_manage_general(player, formname, fields,
|
||||||
-- what_is_the_list_about, min_length, max_length, function_add_new_entry,
|
-- what_is_the_list_about, min_length, max_length, function_add_new_entry,
|
||||||
@ -98,6 +107,13 @@ yl_speak_up.get_fs_manage_quests = function(player, param)
|
|||||||
quest = data
|
quest = data
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- which quest is the player working on? that's important for showing quest steps
|
||||||
|
if(not(yl_speak_up.speak_to[pname])) then
|
||||||
|
yl_speak_up.speak_to[pname] = {}
|
||||||
|
end
|
||||||
|
yl_speak_up.speak_to[pname].q_id = quest.id
|
||||||
|
|
||||||
local quest_state_selected = table.indexof({"created","testing","open","official"}, quest.state)
|
local quest_state_selected = table.indexof({"created","testing","open","official"}, quest.state)
|
||||||
if(quest_state_selected == -1) then
|
if(quest_state_selected == -1) then
|
||||||
quest_state_selected = 1
|
quest_state_selected = 1
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user