added quest_gui as custom action

This commit is contained in:
Sokomine 2022-11-02 16:45:13 +01:00
parent d2d7f30731
commit 4df6a56bf8
5 changed files with 60 additions and 1 deletions

View File

@ -335,6 +335,23 @@ yl_speak_up.custom_functions_a_[ "example function" ] = {
end, end,
} }
-- example function for actions:
yl_speak_up.custom_functions_a_[ "quest maintenance" ] = {
description = "Create and maintain quests.",
-- the actual implementation of the function
-- note that what it shall return is a formspec
code = function(player, n_id, a)
return yl_speak_up.get_fs_quest_gui(player, n_id, a)
end,
-- this function will be called by the one that handles all custom input to actions
-- of the type "evaluate"; it can change the value of entries of the table "fields"
-- if necessary
code_input_handler = function(player, n_id, a, formname, fields)
-- the function has to return fields
return yl_speak_up.input_quest_gui(player, formname, fields)
end,
}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- Custom effects (of type "evaluate") -- Custom effects (of type "evaluate")

View File

@ -799,6 +799,9 @@ yl_speak_up.input_fs_action_evaluate = function(player, formname, fields)
yl_speak_up.execute_next_action(player, a_id, true) yl_speak_up.execute_next_action(player, a_id, true)
return return
end end
if(fields.quit) then
return
end
-- else show a message to the player that he ought to decide -- else show a message to the player that he ought to decide
yl_speak_up.show_fs(player, "msg", { yl_speak_up.show_fs(player, "msg", {
input_to = "yl_speak_up:action_evaluate", input_to = "yl_speak_up:action_evaluate",

29
fs_quest_gui.lua Normal file
View File

@ -0,0 +1,29 @@
yl_speak_up.input_quest_gui = function(player, formname, fields)
-- this return value is necessary for custom actions
local ret = {quit = true}
local pname = player:get_player_name()
if(fields and fields.back_from_msg) then
yl_speak_up.show_fs(player, "quest_gui")
return ret
end
-- new variables have to be added (and deleted) somewhere after all
if(fields.manage_variables) then
-- remember which formspec we are comming from
yl_speak_up.speak_to[pname][ "working_at" ] = "quest_gui"
yl_speak_up.show_fs(player, "manage_variables")
return ret
end
-- the calling NPC shall no longer do anything
return ret
end
yl_speak_up.get_fs_quest_gui = function(player, param)
local pname = player:get_player_name()
return "size[10,2]"..
"label[0,0.5;Hi. This is a quest admin gui.]"..
"button[0.2,1.0;4.0,0.6;manage_variables;Manage variables]"
end

View File

@ -120,6 +120,8 @@ yl_speak_up.reload = function(modpath, log_entry)
dofile(modpath .. "fs_properties.lua") dofile(modpath .. "fs_properties.lua")
-- the main functionality of the mod -- the main functionality of the mod
dofile(modpath .. "functions.lua") dofile(modpath .. "functions.lua")
-- creating and maintaining quests
dofile(modpath .. "fs_quest_gui.lua")
-- initialize and load all registered generic dialogs -- initialize and load all registered generic dialogs
yl_speak_up.load_generic_dialogs() yl_speak_up.load_generic_dialogs()

View File

@ -100,6 +100,10 @@ yl_speak_up.input_handler = function(player, formname, fields)
elseif formname == "yl_speak_up:show_what_points_to_this_dialog" then elseif formname == "yl_speak_up:show_what_points_to_this_dialog" then
yl_speak_up.input_fs_show_what_points_to_this_dialog(player, formname, fields) yl_speak_up.input_fs_show_what_points_to_this_dialog(player, formname, fields)
return true return true
-- create and manage quests
elseif formname == "yl_speak_up:quest_gui" then
yl_speak_up.input_quest_gui(player, formname, fields)
return true
end end
end end
@ -376,7 +380,7 @@ yl_speak_up.show_fs = function(player, fs_name, param)
elseif(fs_name == "action_evaluate") then elseif(fs_name == "action_evaluate") then
yl_speak_up.show_fs_ver(pname, "yl_speak_up:action_evaluate", yl_speak_up.show_fs_ver(pname, "yl_speak_up:action_evaluate",
yl_speak_up.get_fs_action_evaluate(player, param), 1) yl_speak_up.get_fs_action_evaluate(player, param))
elseif(fs_name == "manage_variables") then elseif(fs_name == "manage_variables") then
yl_speak_up.show_fs_ver(pname, "yl_speak_up:manage_variables", yl_speak_up.show_fs_ver(pname, "yl_speak_up:manage_variables",
@ -386,6 +390,10 @@ yl_speak_up.show_fs = function(player, fs_name, param)
yl_speak_up.show_fs_ver(pname, "yl_speak_up:show_what_points_to_this_dialog", yl_speak_up.show_fs_ver(pname, "yl_speak_up:show_what_points_to_this_dialog",
yl_speak_up.show_what_points_to_this_dialog(player, param)) yl_speak_up.show_what_points_to_this_dialog(player, param))
elseif(fs_name == "quest_gui") then
yl_speak_up.show_fs_ver(pname, "yl_speak_up:quest_gui",
yl_speak_up.get_fs_quest_gui(player, param))
-- fallback in case of wrong call -- fallback in case of wrong call
else else
minetest.chat_send_player(pname, "Error: Trying to show wrong ".. minetest.chat_send_player(pname, "Error: Trying to show wrong "..