allow to add or delete locations for quests

This commit is contained in:
Sokomine 2023-09-30 13:21:13 +02:00
parent 36ed71ae56
commit f12f778b06

View File

@ -179,6 +179,20 @@ yl_speak_up.input_fs_add_quest_steps = function(player, formname, fields)
end
return yl_speak_up.show_fs(player, "add_quest_steps")
elseif(fields.add_to_location_list
and yl_speak_up.speak_to[pname].list_available) then
-- selected a location from the list of available locations offered
local liste = yl_speak_up.speak_to[pname].list_available
local selected = minetest.explode_table_event(fields.add_to_location_list)
if(selected and selected.row and selected.row > 1 and selected.row <= #liste + 1) then
local location_id = liste[selected.row - 1]
if(table.indexof(res.quest.locations or {}, location_id) == -1) then
table.insert(yl_speak_up.quests[q_id].locations, location_id)
yl_speak_up.save_quest(q_id)
end
end
return yl_speak_up.show_fs(player, "add_quest_steps")
elseif(fields.delete_from_one_step_required and current_step and step_data[current_step]) then
-- remove a quest step from the list (from one step required)
local selected = minetest.explode_table_event(fields.delete_from_one_step_required)
@ -209,6 +223,17 @@ yl_speak_up.input_fs_add_quest_steps = function(player, formname, fields)
end
yl_speak_up.save_quest(q_id)
return yl_speak_up.show_fs(player, "add_quest_steps")
elseif(fields.delete_from_location_list) then
-- remove a location from the list of contributors
-- TODO: check if it *can* be removed
local selected = minetest.explode_table_event(fields.delete_from_location_list)
local liste = (res.quest.locations or {})
if(selected and selected.row and selected.row > 1 and selected.row <= #liste + 1) then
table.remove(yl_speak_up.quests[q_id].locations, selected.row - 1)
end
yl_speak_up.save_quest(q_id)
return yl_speak_up.show_fs(player, "add_quest_steps")
end
if(mode == "embedded_select") then