removed deprecated precondition "custom" - use "evaluate" instead
This commit is contained in:
parent
6b3e4f8fd8
commit
fdc4464fd2
@ -145,14 +145,14 @@ yl_speak_up.check_and_add_as_generic_dialog = function(dialog, n_id)
|
|||||||
local prereq = option.o_prerequisites
|
local prereq = option.o_prerequisites
|
||||||
if(prereq) then
|
if(prereq) then
|
||||||
for p_id, p in pairs(prereq) do
|
for p_id, p in pairs(prereq) do
|
||||||
if(p.p_type ~= "state" and p.p_type ~= "player_inv" and p.p_type ~= "custom"
|
if(p.p_type ~= "state" and p.p_type ~= "player_inv" and p.p_type ~= "evaluate"
|
||||||
and p.p_type ~= "property"
|
and p.p_type ~= "property" and p.p_type ~= "function"
|
||||||
and p.p_type ~= "true" and p.p_type ~= "false") then
|
and p.p_type ~= "true" and p.p_type ~= "false") then
|
||||||
return "Precondition "..tostring(p_id)..
|
return "Precondition "..tostring(p_id)..
|
||||||
" of option "..tostring(one_option)..
|
" of option "..tostring(one_option)..
|
||||||
" of dialog "..tostring(d_id)..
|
" of dialog "..tostring(d_id)..
|
||||||
" has unsupported type: "..tostring(p.p_type)..
|
" has unsupported type: "..tostring(p.p_type)..
|
||||||
". Supported types: state, property, player_inv and custom."
|
". Supported types: state, property, evaluate, function and player_inv."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -176,7 +176,7 @@ yl_speak_up.check_and_add_as_generic_dialog = function(dialog, n_id)
|
|||||||
and p.p_type ~= "player_inv"
|
and p.p_type ~= "player_inv"
|
||||||
and p.p_type ~= "player_offered_item"
|
and p.p_type ~= "player_offered_item"
|
||||||
and p.p_type ~= "function"
|
and p.p_type ~= "function"
|
||||||
and p.p_type ~= "custom"
|
and p.p_type ~= "evaluate"
|
||||||
and p.p_type ~= "property"
|
and p.p_type ~= "property"
|
||||||
-- depends on the preconditions of another option
|
-- depends on the preconditions of another option
|
||||||
and p.p_type ~= "other"
|
and p.p_type ~= "other"
|
||||||
|
@ -96,7 +96,7 @@ yl_speak_up.custom_server_functions.precondition_eval = function(player, descr,
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- a custom precondition; still works, but less useful than the above method.
|
-- Custom preconditions are deprecated.
|
||||||
-- Please use
|
-- Please use
|
||||||
-- yl_speak_up.custom_server_functions.precondition_descriptions = {..}
|
-- yl_speak_up.custom_server_functions.precondition_descriptions = {..}
|
||||||
-- and
|
-- and
|
||||||
@ -104,12 +104,6 @@ end
|
|||||||
-- instead!
|
-- instead!
|
||||||
-- has to return either true (=precondition is fulfilled) or false (=precondition is not fulfilled)
|
-- has to return either true (=precondition is fulfilled) or false (=precondition is not fulfilled)
|
||||||
-- Note: This function will be called often. Make it efficient!
|
-- Note: This function will be called often. Make it efficient!
|
||||||
yl_speak_up.precondition_custom = function(player, param)
|
|
||||||
minetest.chat_send_player(player:get_player_name(),
|
|
||||||
"Checking custom precondition with parameter \""..tostring(param).."\"..")
|
|
||||||
-- return if your precondition is fulfilled (true) or not (false)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
@ -232,8 +226,14 @@ yl_speak_up.custom_functions_p_[ "example function" ] = {
|
|||||||
param9_desc = "This is the value passed to the function as 9. parameter.",
|
param9_desc = "This is the value passed to the function as 9. parameter.",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
yl_speak_up.custom_functions_p_[ "get_level_of_player" ] = {
|
||||||
|
function_call = "yl_speak_up.get_player_level",
|
||||||
|
description = "Get the level the player has achieved.",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
-- TODO: actually implement these as examples
|
-- TODO: actually implement these as examples
|
||||||
yl_speak_up.custom_functions_p_[ "set_variable_to_random_number" ] = {
|
yl_speak_up.custom_functions_r_[ "set_variable_to_random_number" ] = {
|
||||||
function_call = "yl_speak_up.set_variable_to_random_number",
|
function_call = "yl_speak_up.set_variable_to_random_number",
|
||||||
description = "Set a variable to a random number.",
|
description = "Set a variable to a random number.",
|
||||||
param1_text = "Name of the variable:",
|
param1_text = "Name of the variable:",
|
||||||
@ -244,7 +244,7 @@ yl_speak_up.custom_functions_p_[ "set_variable_to_random_number" ] = {
|
|||||||
param3_desc = "Which is the MAXIMUM value the varible might be set to?",
|
param3_desc = "Which is the MAXIMUM value the varible might be set to?",
|
||||||
}
|
}
|
||||||
|
|
||||||
yl_speak_up.custom_functions_p_[ "set_variable_to_random_value_from_list" ] = {
|
yl_speak_up.custom_functions_r_[ "set_variable_to_random_value_from_list" ] = {
|
||||||
function_call = "yl_speak_up.select_random_value_from_list",
|
function_call = "yl_speak_up.select_random_value_from_list",
|
||||||
description = "Set a variable to a random value from a list.",
|
description = "Set a variable to a random value from a list.",
|
||||||
param1_text = "Name of the variable:",
|
param1_text = "Name of the variable:",
|
||||||
@ -255,12 +255,6 @@ yl_speak_up.custom_functions_p_[ "set_variable_to_random_value_from_list" ] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
yl_speak_up.custom_functions_p_[ "get_level_of_player" ] = {
|
|
||||||
function_call = "yl_speak_up.get_player_level",
|
|
||||||
description = "Get the level the player has achieved.",
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
-- example function for results/effects:
|
-- example function for results/effects:
|
||||||
yl_speak_up.custom_functions_r_[ "example function" ] = {
|
yl_speak_up.custom_functions_r_[ "example function" ] = {
|
||||||
function_call = "yl_speak_up.custom_example_function",
|
function_call = "yl_speak_up.custom_example_function",
|
||||||
|
@ -393,9 +393,6 @@ yl_speak_up.eval_precondition = function(player, n_id, p, other_options_true_or_
|
|||||||
end
|
end
|
||||||
-- all ok
|
-- all ok
|
||||||
return true
|
return true
|
||||||
elseif(p.p_type == "custom") then
|
|
||||||
-- execute the custom function
|
|
||||||
return yl_speak_up.precondition_custom(player, p.p_value)
|
|
||||||
elseif(p.p_type == "other") then
|
elseif(p.p_type == "other") then
|
||||||
-- are the preconditions of another option fulfilled?
|
-- are the preconditions of another option fulfilled?
|
||||||
return (p.p_value
|
return (p.p_value
|
||||||
|
@ -60,9 +60,6 @@
|
|||||||
-- a function ("function"): requires npc_master to create and edit
|
-- a function ("function"): requires npc_master to create and edit
|
||||||
-- p_value the lua code to execute and evaulate
|
-- p_value the lua code to execute and evaulate
|
||||||
--
|
--
|
||||||
-- a custom function ("custon"):
|
|
||||||
-- p_value parameter for the custom function
|
|
||||||
--
|
|
||||||
-- depends on another option:
|
-- depends on another option:
|
||||||
-- p_value name of the other option of this dialog that is considered
|
-- p_value name of the other option of this dialog that is considered
|
||||||
-- p_fulfilled shall option p_value be true or false?
|
-- p_fulfilled shall option p_value be true or false?
|
||||||
@ -84,7 +81,6 @@ local check_what = {
|
|||||||
"the inventory of a block somewhere", -- 7
|
"the inventory of a block somewhere", -- 7
|
||||||
"an item the player offered/gave to the NPC", -- 8
|
"an item the player offered/gave to the NPC", -- 8
|
||||||
"execute Lua code (requires npc_master priv)", -- 7 -> 9
|
"execute Lua code (requires npc_master priv)", -- 7 -> 9
|
||||||
"Call custom functions that are supposed to be overridden by the server.", -- 8 -> 10
|
|
||||||
"The preconditions of another dialog option are fulfilled/not fulfilled.", -- 9 -> 11
|
"The preconditions of another dialog option are fulfilled/not fulfilled.", -- 9 -> 11
|
||||||
"nothing - always true (useful for generic dialogs)",
|
"nothing - always true (useful for generic dialogs)",
|
||||||
"nothing - always false (useful for temporally deactivating an option)",
|
"nothing - always false (useful for temporally deactivating an option)",
|
||||||
@ -96,8 +92,6 @@ local values_what = {"", "state", "property", "evaluate", "block", "trade",
|
|||||||
"player_offered_item",
|
"player_offered_item",
|
||||||
-- "function" requires npc_master priv:
|
-- "function" requires npc_master priv:
|
||||||
"function",
|
"function",
|
||||||
-- custom function (does not require npc_master priv)
|
|
||||||
"custom",
|
|
||||||
-- depends on the preconditions of another option
|
-- depends on the preconditions of another option
|
||||||
"other",
|
"other",
|
||||||
"true", "false"}
|
"true", "false"}
|
||||||
@ -327,8 +321,6 @@ yl_speak_up.show_precondition = function(p, pname)
|
|||||||
else
|
else
|
||||||
return "The player offered "..tostring(match).." of \""..tostring(item).."\"."
|
return "The player offered "..tostring(match).." of \""..tostring(item).."\"."
|
||||||
end
|
end
|
||||||
elseif(p.p_type == "custom") then
|
|
||||||
return "Call custom function with param: \""..tostring(p.p_value).."\"."
|
|
||||||
elseif(p.p_type == "other") then
|
elseif(p.p_type == "other") then
|
||||||
local fulfilled = "fulfilled"
|
local fulfilled = "fulfilled"
|
||||||
if(not(p.p_fulfilled) or p.p_fulfilled ~= "true") then
|
if(not(p.p_fulfilled) or p.p_fulfilled ~= "true") then
|
||||||
|
Loading…
Reference in New Issue
Block a user