added buttons to connect manage variables and manage quests

This commit is contained in:
Sokomine 2022-11-14 19:13:27 +01:00
parent 8b24e9b52f
commit 1ad1da470f
2 changed files with 23 additions and 4 deletions

View File

@ -31,6 +31,10 @@ yl_speak_up.input_fs_manage_quests_check_fields = function(player, formname, fie
if(not(quest_name)) then
quest_name = ""
end
if(fields and fields.show_variable) then
yl_speak_up.show_fs(player, "manage_variables", quest_name)
return
end
-- this function didn't have anything to do
return "NOTHING FOUND"
end
@ -55,6 +59,10 @@ yl_speak_up.get_fs_manage_quests = function(player, param)
local pname = player:get_player_name()
local quest_list = yl_speak_up.get_sorted_quest_list(pname)
local formspec = {}
if(param and param ~= "") then
local index = table.indexof(quest_list, param)
yl_speak_up.speak_to[pname].tmp_index_general = index + 1
end
table.insert(formspec, "size[18,12]"..
"label[0.2,1.2;A quest is a linear sequence of quest steps. Quests can "..
"depend on and influence other quests.\n"..
@ -74,6 +82,7 @@ yl_speak_up.get_fs_manage_quests = function(player, param)
if(selected and selected ~= "") then
local k = selected
-- index 1 is "Add variable:"
table.insert(formspec, "button[12,2.15;4.5,0.6;show_variable;Show and edit this variable]")
end
return table.concat(formspec, "")
end

View File

@ -37,6 +37,10 @@ yl_speak_up.input_fs_manage_variables_check_fields = function(player, formname,
formspec = yl_speak_up.fs_show_all_var_values(player, pname, var_name)
})
return
-- show details about a quest (if it is a quest variable)
elseif(fields and fields.show_quest) then
yl_speak_up.show_fs(player, "manage_quests", var_name)
return
-- show where this variable is used
elseif(fields and fields.show_var_usage and fields.show_var_usage ~= "") then
yl_speak_up.show_fs(player, "msg", {
@ -291,6 +295,10 @@ yl_speak_up.get_fs_manage_variables = function(player, param)
yl_speak_up.strip_pname_from_varlist(var_list, pname)
local formspec = {}
if(param and param ~= "") then
local index = table.indexof(var_list, param)
yl_speak_up.speak_to[pname].tmp_index_general = index + 1
end
table.insert(formspec, "size[18,12]"..
"label[0.2,1.2;Note: Each variable will store a diffrent value for each "..
"player who interacts with the NPC.\n"..
@ -434,12 +442,14 @@ yl_speak_up.get_fs_manage_variables = function(player, param)
"If you click here, the selected player\n"..
"will no longer be able to *write* new\n"..
"values into this variable."))
local var_type = (yl_speak_up.get_variable_metadata(k_long, "var_type")
or "String/text or numerical value, depending on how you use it")
table.insert(formspec, "label[0.2,5.05;Type of variable: ")
table.insert(formspec, -- show variable type
minetest.colorize("#FFFF00",
(yl_speak_up.get_variable_metadata(k_long, "var_type")
or "String/text or numerical value, depending on how you use it")))
table.insert(formspec, minetest.colorize("#FFFF00", var_type)) -- show variable type
table.insert(formspec, ".]")
if(var_type == "quest") then
table.insert(formspec, "button[4.2,4.75;4.5,0.6;show_quest;Show and edit this quest]")
end
table.insert(formspec, "label[0.2,6.05;This variable is used by the following ")
table.insert(formspec,
minetest.colorize("#FFFF00", tostring(c1)).." NPC:\n\t"..