mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-06-19 13:48:02 +02:00
show start, end and unconnected quest steps
This commit is contained in:
parent
fd35e172d8
commit
1347fb1bdb
@ -300,11 +300,13 @@ yl_speak_up.get_fs_add_quest_steps = function(player, param)
|
||||
end
|
||||
|
||||
local formspec = {}
|
||||
if(mode and mode ~= "embedded_select") then
|
||||
table.insert(formspec, "size[12.5,17.3]")
|
||||
else
|
||||
table.insert(formspec, "size[12.5,12.5]")
|
||||
local x_add = 0
|
||||
if(mode and mode == "embedded_select") then
|
||||
table.insert(formspec, "size[30,12]container[6,0;18.5,12]")
|
||||
current_step = nil
|
||||
x_add = 5
|
||||
else
|
||||
table.insert(formspec, "size[12.5,17.3]")
|
||||
end
|
||||
-- add back button
|
||||
table.insert(formspec, "button[8,0;2,0.7;back;Back]")
|
||||
@ -419,7 +421,7 @@ yl_speak_up.get_fs_add_quest_steps = function(player, param)
|
||||
table.insert(formspec, ":]")
|
||||
end
|
||||
yl_speak_up.quest_step_list_show_table(formspec,
|
||||
"0.2,"..tostring(y_pos + 0.2)..";12.0,6.0;add_from_available;",
|
||||
"0.2,"..tostring(y_pos + 0.2)..";"..tostring(12+x_add)..",6.0;add_from_available;",
|
||||
available_steps,
|
||||
step_data, required_for_steps)
|
||||
table.insert(formspec, "label[0.2,")
|
||||
|
@ -59,6 +59,48 @@ yl_speak_up.quest_step_required_for = function(step_data, this_step)
|
||||
end
|
||||
|
||||
|
||||
-- sorts quest steps into lists: start, middle, end, unconnected
|
||||
yl_speak_up.quest_step_get_start_end_unconnected_lists = function(step_data)
|
||||
local start_steps = {}
|
||||
local end_steps = {}
|
||||
local unconnected_steps = {}
|
||||
-- construct tables of *candidates* for start/end steps first
|
||||
for s, d in pairs(step_data) do
|
||||
if(#d.one_step_required == 0 and #d.all_steps_required == 0) then
|
||||
start_steps[s] = true
|
||||
end
|
||||
end_steps[s] = true
|
||||
end
|
||||
for s, d in pairs(step_data) do
|
||||
-- anything that is required somewhere cannot be an end step
|
||||
for i, s2 in ipairs(d.one_step_required or {}) do
|
||||
end_steps[s2] = nil
|
||||
end
|
||||
for i, s2 in ipairs(d.all_steps_required or {}) do
|
||||
end_steps[s2] = nil
|
||||
end
|
||||
end
|
||||
local lists = {}
|
||||
lists.start_steps = {}
|
||||
lists.end_steps = {}
|
||||
lists.unconnected_steps = {}
|
||||
lists.middle_steps = {}
|
||||
for s, d in pairs(step_data) do
|
||||
-- if it's both a start and end step, then it's an unconnected step
|
||||
if(start_steps[s] and end_steps[s]) then
|
||||
table.insert(lists.unconnected_steps, s)
|
||||
elseif(start_steps[s]) then
|
||||
table.insert(lists.start_steps, s)
|
||||
elseif(end_steps[s]) then
|
||||
table.insert(lists.end_steps, s)
|
||||
else
|
||||
table.insert(lists.middle_steps, s)
|
||||
end
|
||||
end
|
||||
return lists
|
||||
end
|
||||
|
||||
|
||||
-- Imposing an order on the quest steps is...tricky as best as what will
|
||||
-- be more important to the players will be the order in which the
|
||||
-- quest steps have to be solved/done - and not an alphabetical order.
|
||||
@ -269,9 +311,28 @@ yl_speak_up.get_fs_manage_quest_steps = function(player, param)
|
||||
table.insert(formspec, "container_end[]")
|
||||
|
||||
if(not(selected) or selected == "" or not(step_data) or not(step_data[selected])) then
|
||||
formspec = {} -- we start a new one
|
||||
-- insert a nicely formated list of quest steps
|
||||
yl_speak_up.speak_to[res.pname].quest_step_mode = "embedded_select"
|
||||
return yl_speak_up.get_fs_add_quest_steps(player, nil)
|
||||
table.insert(formspec, yl_speak_up.get_fs_add_quest_steps(player, nil))
|
||||
table.insert(formspec, "container_end[]")
|
||||
local lists = yl_speak_up.quest_step_get_start_end_unconnected_lists(step_data)
|
||||
table.insert(formspec, "container[0.1,2.7;5.6,10.8]"..
|
||||
"box[0,0;5.6,8.5;#666666]"..
|
||||
"label[0.1,0.5;Start steps:]"..
|
||||
"label[0.1,4.0;Unconnected steps:]")
|
||||
yl_speak_up.quest_step_show_table(formspec, "0.1,0.7;5.4,2.7;TODO_one_step_required;",
|
||||
lists.start_steps)
|
||||
yl_speak_up.quest_step_show_table(formspec, "0.1,4.2;5.4,4.0;TODO_all_steps_required;",
|
||||
lists.unconnected_steps)
|
||||
table.insert(formspec, "container_end[]")
|
||||
table.insert(formspec, "container[23.8,2.7;5.6,10.8]"..
|
||||
"box[0,0;5.6,8.5;#666666]"..
|
||||
"label[0.2,0.5;Quest ends with steps:]")
|
||||
yl_speak_up.quest_step_show_table(formspec, "0.1,0.7;5.4,7.7;TODO_next_steps_show;",
|
||||
lists.end_steps)
|
||||
table.insert(formspec, "container_end[]")
|
||||
return table.concat(formspec, "")
|
||||
end
|
||||
-- find out the next quest step
|
||||
local required_for = yl_speak_up.quest_step_required_for(step_data, selected)
|
||||
|
Loading…
Reference in New Issue
Block a user