forked from your-land-mirror/yl_speak_up
removed obsolete action "custom" (use the new "evaluate" instead)
This commit is contained in:
parent
4dfa9f2ed3
commit
77c05631eb
@ -89,71 +89,6 @@ yl_speak_up.custom_server_functions.precondition_eval = function(player, descr,
|
||||
end
|
||||
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Custom actions
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-- a custom action (the formspec shown to the player);
|
||||
-- overwrite this function on your server with a custom one that shows the formspec
|
||||
-- that you want!
|
||||
yl_speak_up.get_fs_action_custom = function(player, param)
|
||||
local pname = player:get_player_name()
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
return "size[8.5,4.0]"..
|
||||
"button[0.2,0.0;2.0,0.9;back_to_talk;Back to talk]"..
|
||||
"button[4.75,0.0;3.0,0.9;finished_action;Stare back]"..
|
||||
"button[4.75,0.8;3.0,0.9;failed_action;Fail to stare back]"..
|
||||
"tooltip[back_to_talk;Click here if you want to abort/cancel.]"..
|
||||
"tooltip[failed_action;Click here if you want the action to FAIL.]"..
|
||||
"tooltip[finished_action;Click here if you want the action to be a SUCCESS.]"..
|
||||
"label[0.5,1.7;"..minetest.formspec_escape(
|
||||
"["..(dialog.n_npc or "- ? -").." stares expectantly at you.]").."]"..
|
||||
"label[0.5,2.5;Your custom parameter is:]"..
|
||||
"label[1.5,3.0;"..minetest.formspec_escape(tostring(param)).."]"..
|
||||
"label[0.5,3.5;Overwrite this function with a custom one!]"
|
||||
end
|
||||
|
||||
|
||||
-- a custom action (checking of the input);
|
||||
-- overwrite this function on your server with a custom one that checks the
|
||||
-- input to your formspec - but don't forget to call the necessary functions
|
||||
-- as shown here
|
||||
yl_speak_up.input_fs_action_custom = function(player, formname, fields)
|
||||
-- back from error_msg? then show the formspec again
|
||||
if(fields.back_from_error_msg) then
|
||||
yl_speak_up.show_fs(player, "action_custom", nil)
|
||||
return
|
||||
end
|
||||
local pname = player:get_player_name()
|
||||
local a_id = yl_speak_up.speak_to[pname].a_id
|
||||
if(fields.back_to_talk) then
|
||||
-- the action was aborted
|
||||
yl_speak_up.execute_next_action(player, a_id, nil)
|
||||
return
|
||||
end
|
||||
if(fields.failed_action) then
|
||||
-- the action failed
|
||||
yl_speak_up.execute_next_action(player, a_id, false)
|
||||
return
|
||||
end
|
||||
if(fields.finished_action) then
|
||||
-- the action was a success
|
||||
yl_speak_up.execute_next_action(player, a_id, true)
|
||||
return
|
||||
end
|
||||
-- else show a message to the player that he ought to decide
|
||||
yl_speak_up.show_fs(player, "msg", {
|
||||
input_to = "yl_speak_up:action_custom",
|
||||
formspec = "size[7,1.0]"..
|
||||
"label[0.2,-0.2;"..
|
||||
"Please click either on \"Stare back\" or \"Back to talk\"!]"..
|
||||
"button[2,0.5;1.5,0.9;back_from_error_msg;Back]"})
|
||||
end
|
||||
|
||||
-- actions: (not yet used)
|
||||
yl_speak_up.custom_functions_a_ = {}
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Custom preconditions, actions and effects
|
||||
-- (they contain functions; they have the type "evaluate")
|
||||
|
@ -265,9 +265,6 @@ yl_speak_up.execute_action = function(player, n_id, o_id, a)
|
||||
elseif(a.a_type == "evaluate") then
|
||||
yl_speak_up.show_fs(player, "action_evaluate", a.a_value)
|
||||
return
|
||||
elseif(a.a_type == "custom") then
|
||||
yl_speak_up.show_fs(player, "action_custom", a.a_value)
|
||||
return
|
||||
end
|
||||
-- fallback: unkown type
|
||||
return false
|
||||
@ -609,10 +606,10 @@ yl_speak_up.input_fs_action_evaluate = function(player, formname, fields)
|
||||
-- else show a message to the player that he ought to decide
|
||||
yl_speak_up.show_fs(player, "msg", {
|
||||
input_to = "yl_speak_up:action_evaluate",
|
||||
formspec = "size[7,1.0]"..
|
||||
formspec = "size[7,1.5]"..
|
||||
"label[0.2,-0.2;"..
|
||||
"Please click on one of the offered options or select \"Back to talk\"!]"..
|
||||
"button[2,0.5;1.5,0.9;back_from_error_msg;Back]"})
|
||||
"Please click on one of the offered options\nor select \"Back to talk\"!]"..
|
||||
"button[2,1.0;1.5,0.9;back_from_error_msg;Back]"})
|
||||
end
|
||||
|
||||
|
||||
|
@ -33,9 +33,6 @@
|
||||
-- ..
|
||||
-- a_param9 the 9th parameter (optional; depends on function)
|
||||
--
|
||||
-- call a custom formspec ("custom"):
|
||||
-- a_value parameter for the custom function
|
||||
--
|
||||
-- a general, more complex formspec-basted puzzle ("puzzle"): not supported
|
||||
-- (custom may be more helpful)
|
||||
--
|
||||
@ -56,12 +53,11 @@ local check_what = {
|
||||
"The player is expected to give something to the NPC (i.e. a quest item).", -- 5
|
||||
"The player has to manually enter a password or passphrase or some other text.", -- 6
|
||||
"Show something custom (has to be provided by the server).",
|
||||
"Call custom functions that are supposed to be overridden by the server.", -- 7
|
||||
-- "The player has to move virtual items in a virtual inventory to the right position.", -- 8
|
||||
}
|
||||
|
||||
-- how to store these as a_type in the action:
|
||||
local values_what = {"", "none", "trade", "npc_gives", "npc_wants", "text_input", "evaluate", "custom", "puzzle"}
|
||||
local values_what = {"", "none", "trade", "npc_gives", "npc_wants", "text_input", "evaluate", "puzzle"}
|
||||
|
||||
|
||||
-- returns a human-readable text as description of the action
|
||||
@ -94,8 +90,6 @@ yl_speak_up.show_action = function(a)
|
||||
-- puzzle is unused; better do that via custom
|
||||
-- elseif(a.a_type == "puzzle") then
|
||||
-- return "puzzle:"
|
||||
elseif(a.a_type == "custom") then
|
||||
return "Call custom function with param: \""..tostring(a.a_value).."\"."
|
||||
end
|
||||
-- fallback
|
||||
return tostring(a.a_value)
|
||||
|
@ -74,9 +74,6 @@ minetest.register_on_player_receive_fields( function(player, formname, fields)
|
||||
elseif formname == "yl_speak_up:action_evaluate" then
|
||||
yl_speak_up.input_fs_action_evaluate(player, formname, fields)
|
||||
return true
|
||||
elseif formname == "yl_speak_up:action_custom" then
|
||||
yl_speak_up.input_fs_action_custom(player, formname, fields)
|
||||
return true
|
||||
-- handled in fs_edit_effects.lua
|
||||
elseif formname == "yl_speak_up:edit_effects" then
|
||||
yl_speak_up.input_fs_edit_effects(player, formname, fields)
|
||||
@ -338,10 +335,6 @@ yl_speak_up.show_fs = function(player, fs_name, param)
|
||||
yl_speak_up.show_fs_ver(pname, "yl_speak_up:action_evaluate",
|
||||
yl_speak_up.get_fs_action_evaluate(player, param))
|
||||
|
||||
elseif(fs_name == "action_custom") then
|
||||
yl_speak_up.show_fs_ver(pname, "yl_speak_up:action_custom",
|
||||
yl_speak_up.get_fs_action_custom(player, param))
|
||||
|
||||
elseif(fs_name == "manage_variables") then
|
||||
yl_speak_up.show_fs_ver(pname, "yl_speak_up:manage_variables",
|
||||
yl_speak_up.get_fs_manage_variables(player, param))
|
||||
|
Loading…
Reference in New Issue
Block a user