prepared adding quest steps
This commit is contained in:
parent
decae6977e
commit
6ecf800a60
@ -62,12 +62,54 @@ end
|
|||||||
yl_speak_up.input_fs_add_quest_steps = function(player, formname, fields)
|
yl_speak_up.input_fs_add_quest_steps = function(player, formname, fields)
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
|
|
||||||
|
if(not(pname) or not(yl_speak_up.speak_to[pname])) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if(fields and fields.back_from_error_msg) then
|
||||||
|
yl_speak_up.show_fs(player, "add_quest_steps")
|
||||||
|
return
|
||||||
|
end
|
||||||
if(fields and fields.back) then
|
if(fields and fields.back) then
|
||||||
if(pname and yl_speak_up.speak_to[pname] and yl_speak_up.speak_to[pname].quest_step) then
|
if(yl_speak_up.speak_to[pname].quest_step) then
|
||||||
yl_speak_up.show_fs(player, "manage_quest_steps", yl_speak_up.speak_to[pname].quest_step)
|
yl_speak_up.show_fs(player, "manage_quest_steps", yl_speak_up.speak_to[pname].quest_step)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- has a quest step be selected?
|
||||||
|
local work_step = nil
|
||||||
|
if(fields and fields.add_step and fields.add_quest_step) then
|
||||||
|
local q_id = yl_speak_up.speak_to[pname].q_id
|
||||||
|
local new_step = fields.add_quest_step:trim()
|
||||||
|
-- a new one shall be created
|
||||||
|
local res = yl_speak_up.quest_step_add_quest_step(pname, q_id, new_step)
|
||||||
|
if(res ~= "OK") then
|
||||||
|
yl_speak_up.show_fs(player, "msg", {
|
||||||
|
input_to = "yl_speak_up:add_quest_steps",
|
||||||
|
formspec = "size[9,2]"..
|
||||||
|
"label[0.2,0.0;Error:\n"..
|
||||||
|
minetest.formspec_escape(minetest.wrap_text(res,80)).."]"..
|
||||||
|
"button[1.5,1.5;2,0.9;back_from_error_msg;Back]"})
|
||||||
|
return res
|
||||||
|
end
|
||||||
|
-- this will also be set if the quest step exists already; this is fine so far
|
||||||
|
work_step = new_step
|
||||||
|
|
||||||
|
elseif(fields.add_from_available and pname and yl_speak_up.speak_to[pname]
|
||||||
|
and yl_speak_up.speak_to[pname].available_quest_steps) then
|
||||||
|
local liste = yl_speak_up.speak_to[pname].available_quest_steps
|
||||||
|
local selected = minetest.explode_table_event(fields.add_from_available)
|
||||||
|
if(selected and selected.row and selected.row > 1 and selected.row <= #liste + 1) then
|
||||||
|
work_step = liste[selected.row - 1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(work_step) then
|
||||||
|
-- minetest.chat_send_player("singleplayer","SELECTED: "..tostring(work_step)) -- TODO
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- minetest.chat_send_player("singleplayer","FIELDS: "..minetest.serialize(fields))
|
||||||
|
-- TODO: implement
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -90,6 +132,7 @@ yl_speak_up.quest_step_list_show_table = function(formspec, table_specs, liste,
|
|||||||
"color;text,align=left".. -- name of quest step
|
"color;text,align=left".. -- name of quest step
|
||||||
"]table[")
|
"]table[")
|
||||||
table.insert(formspec, table_specs)
|
table.insert(formspec, table_specs)
|
||||||
|
table.insert(formspec,"#FFFFFF,(O),#FFFFFF,(A),#FFFFFF,(U),#FFFFFF,Name of step:,")
|
||||||
local tmp = {}
|
local tmp = {}
|
||||||
for i, s in ipairs(liste or {}) do
|
for i, s in ipairs(liste or {}) do
|
||||||
local d = data[s]
|
local d = data[s]
|
||||||
@ -149,7 +192,7 @@ yl_speak_up.get_fs_add_quest_steps = function(player, param)
|
|||||||
|
|
||||||
|
|
||||||
local formspec = {}
|
local formspec = {}
|
||||||
table.insert(formspec, "size[12.5,16]")
|
table.insert(formspec, "size[12.5,17.3]")
|
||||||
-- add back button
|
-- add back button
|
||||||
table.insert(formspec, "button[8,0;2,0.7;back;Back]")
|
table.insert(formspec, "button[8,0;2,0.7;back;Back]")
|
||||||
-- show which quest we're working at
|
-- show which quest we're working at
|
||||||
@ -242,6 +285,7 @@ yl_speak_up.get_fs_add_quest_steps = function(player, param)
|
|||||||
table.insert(available_steps, k)
|
table.insert(available_steps, k)
|
||||||
end
|
end
|
||||||
table.sort(available_steps)
|
table.sort(available_steps)
|
||||||
|
yl_speak_up.speak_to[pname].available_quest_steps = available_steps
|
||||||
table.insert(formspec, "label[0.2,")
|
table.insert(formspec, "label[0.2,")
|
||||||
table.insert(formspec, tostring(y_pos))
|
table.insert(formspec, tostring(y_pos))
|
||||||
table.insert(formspec, ";or select an existing quest step from the list below:]")
|
table.insert(formspec, ";or select an existing quest step from the list below:]")
|
||||||
@ -249,6 +293,12 @@ yl_speak_up.get_fs_add_quest_steps = function(player, param)
|
|||||||
"0.2,"..tostring(y_pos + 0.2)..";12.0,6.0;add_from_available;",
|
"0.2,"..tostring(y_pos + 0.2)..";12.0,6.0;add_from_available;",
|
||||||
available_steps,
|
available_steps,
|
||||||
step_data, required_for_steps)
|
step_data, required_for_steps)
|
||||||
|
table.insert(formspec, "label[0.2,")
|
||||||
|
table.insert(formspec, tostring(y_pos + 6.5))
|
||||||
|
table.insert(formspec, ";Legend: The numbers show the amount of quest steps...\n"..
|
||||||
|
"\t(O) from which (o)ne needs to be achieved for this quest step\n"..
|
||||||
|
"\t(A) that (a)ll need to be achieved for this quest step\n"..
|
||||||
|
"\t(U) that require/(u)se this quest step in some form]")
|
||||||
|
|
||||||
-- TODO: write before which quest step we want to insert (if that is what is selected)
|
-- TODO: write before which quest step we want to insert (if that is what is selected)
|
||||||
return table.concat(formspec, "")
|
return table.concat(formspec, "")
|
||||||
|
Loading…
Reference in New Issue
Block a user