improved quest step management

This commit is contained in:
Sokomine 2023-09-20 22:43:06 +02:00
parent 83f92f1a49
commit 4bcbf8ee0a

View File

@ -118,6 +118,10 @@ 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(fields and fields.back) then
yl_speak_up.show_fs(player, "manage_quests")
return
end
local res = yl_speak_up.player_is_working_on_quest(player)
if(not(res.error_msg) and res.current_step) then
local selected_from = nil
@ -194,23 +198,24 @@ yl_speak_up.get_fs_manage_quest_steps = function(player, param)
return minetest.colorize("#9999FF", text)
end
-- TODO: check if the player is allowed to access that quest
local pname = player:get_player_name()
local formspec = {}
local q_id = yl_speak_up.speak_to[pname].q_id
local quest = yl_speak_up.quests[q_id]
local step_data = quest.step_data
local quest_step_list = yl_speak_up.get_sorted_quest_step_list(pname)
local res = yl_speak_up.player_is_working_on_quest(player)
if(res.error_msg) then
return "size[9,2]"..
"label[0,0;"..minetest.formspec_escape("Error: "..tostring(res.error_msg)).."]"..
"button[1.5,1.5;2,0.9;back;Back]"
end
local step_data = res.step_data
local quest_step_list = yl_speak_up.get_sorted_quest_step_list(res.pname)
if(param and param ~= "") then
local index = table.indexof(quest_step_list, param)
yl_speak_up.speak_to[pname].tmp_index_general = index + 1
yl_speak_up.speak_to[res.pname].tmp_index_general = index + 1
end
local idx = yl_speak_up.speak_to[pname].tmp_index_general
local idx = yl_speak_up.speak_to[res.pname].tmp_index_general
if(idx and idx > 1) then
yl_speak_up.speak_to[pname].quest_step = quest_step_list[idx - 1]
yl_speak_up.speak_to[res.pname].quest_step = quest_step_list[idx - 1]
end
local formspec = {}
table.insert(formspec, "size[30,12]"..
"container[6,0;18.5,12]"..
"label[0.2,1.2;A quest step is a single thing a player may do in a quest - "..