passing mode of how/where to add new quest steps differntly now

This commit is contained in:
Sokomine 2023-09-19 00:32:32 +02:00
parent 5ba53ba637
commit 352a0322f4
2 changed files with 22 additions and 10 deletions

View File

@ -172,26 +172,26 @@ yl_speak_up.get_fs_add_quest_steps = function(player, param)
current_step = yl_speak_up.speak_to[pname].quest_step
this_step_data = step_data[current_step]
end
local fields = nil
if(param and type(param) == "table" and param.fields and type(param.fields) == "table") then
fields = param.fields
local mode = ""
if(pname and yl_speak_up.speak_to[pname] and yl_speak_up.speak_to[pname].quest_step_mode) then
mode = yl_speak_up.speak_to[pname].quest_step_mode
end
local y_pos = 3.3
if(fields and current_step and fields.insert_after_prev_step) then
if(current_step and mode == "insert_after_prev_step") then
local prev_step = "-"
if(this_step_data and this_step_data.one_step_required and #this_step_data.one_step_required > 0) then
prev_step = #this_step_data.one_step_required[1]
end
table.insert(formspec, "label[0.2,3.3;between the previous step:]")
table.insert(formspec, "label[1.0,3.7;")
table.insert(formspec, minetest.colorize("#9999FF", minetest.formspec_escape(prev_step)))
table.insert(formspec, minetest.colorize("#AAFFAA", minetest.formspec_escape(prev_step)))
table.insert(formspec, "]")
table.insert(formspec, "label[0.2,4.1;and the currently selected step:]")
table.insert(formspec, "label[1.0,4.5;")
table.insert(formspec, minetest.colorize("#FFFF00", minetest.formspec_escape(current_step)))
table.insert(formspec, "]")
y_pos = 5.3
elseif(fields and current_step and fields.insert_before_next_step) then
elseif(current_step and mode == "insert_before_next_step") then
local next_step = "-"
if(current_step and required_for_steps[current_step] and #required_for_steps[current_step] > 0) then
next_step = #required_for_steps[current_step][1]
@ -205,7 +205,7 @@ yl_speak_up.get_fs_add_quest_steps = function(player, param)
table.insert(formspec, minetest.colorize("#AAFFAA", minetest.formspec_escape(next_step)))
table.insert(formspec, "]")
y_pos = 5.3
elseif(fields and current_step and fields.add_to_one_needed) then
elseif(current_step and mode == "add_to_one_needed") then
table.insert(formspec, "label[0.2,3.3;as a requirement to the currently selected step:]")
table.insert(formspec, "label[1.0,3.7;")
table.insert(formspec, minetest.colorize("#FFFF00", minetest.formspec_escape(current_step)))
@ -219,13 +219,13 @@ yl_speak_up.get_fs_add_quest_steps = function(player, param)
step_data, required_for_steps)
table.insert(formspec, "label[0.2,7.5;(Click on an entry to delete it from the list above.)]")
y_pos = 8.3
elseif(fields and current_step and fields.add_to_all_needed) then
elseif(current_step and mode == "add_to_all_needed") then
table.insert(formspec, "label[0.2,3.3;as a requirement to the currently selected step:]")
table.insert(formspec, "label[1.0,3.7;")
table.insert(formspec, minetest.colorize("#FFFF00", minetest.formspec_escape(current_step)))
table.insert(formspec, "]")
table.insert(formspec, "label[0.2,4.1;so that "..
minetest.colorize("#AAFFAA", "all")..
minetest.colorize("#9999FF", "all")..
" of these requirements are fulfilled:]")
yl_speak_up.quest_step_list_show_table(formspec,
"0.2,4.3;11.0,3.0;delete_from_all_steps_required;",
@ -240,6 +240,7 @@ yl_speak_up.get_fs_add_quest_steps = function(player, param)
for k, v in pairs(step_data) do
table.insert(available_steps, k)
end
table.sort(available_steps)
table.insert(formspec, "label[0.2,")
table.insert(formspec, tostring(y_pos))
table.insert(formspec, ";or select an existing quest step from the list below:]")

View File

@ -80,7 +80,18 @@ yl_speak_up.input_fs_manage_quest_steps = function(player, formname, fields)
-- let that function sort out what to do;
-- yl_speak_up.speak_to[pname].q_id and yl_speak_up.speak_to[pname].quest_step
-- ought to be set to the current quest and step by now
yl_speak_up.show_fs(player, "add_quest_steps", {fields=fields})
if(fields.add_to_one_needed) then
yl_speak_up.speak_to[pname].quest_step_mode = "add_to_one_needed"
elseif(fields.add_to_all_needed) then
yl_speak_up.speak_to[pname].quest_step_mode = "add_to_all_needed"
elseif(fields.insert_after_prev_step) then
yl_speak_up.speak_to[pname].quest_step_mode = "insert_after_prev_step"
elseif(fields.insert_before_next_step) then
yl_speak_up.speak_to[pname].quest_step_mode = "insert_before_next_step"
else
yl_speak_up.speak_to[pname].quest_step_mode = nil
end
yl_speak_up.show_fs(player, "add_quest_steps")
return
end
local quest_step_list = yl_speak_up.get_sorted_quest_step_list(pname)