diff --git a/add_generic_dialogs.lua b/add_generic_dialogs.lua index a5a7527..83dc3fe 100644 --- a/add_generic_dialogs.lua +++ b/add_generic_dialogs.lua @@ -145,14 +145,14 @@ yl_speak_up.check_and_add_as_generic_dialog = function(dialog, n_id) local prereq = option.o_prerequisites if(prereq) then for p_id, p in pairs(prereq) do - if(p.p_type ~= "state" and p.p_type ~= "player_inv" and p.p_type ~= "custom" - and p.p_type ~= "property" + 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 ~= "function" and p.p_type ~= "true" and p.p_type ~= "false") then return "Precondition "..tostring(p_id).. " of option "..tostring(one_option).. " of dialog "..tostring(d_id).. " 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 @@ -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_offered_item" and p.p_type ~= "function" - and p.p_type ~= "custom" + and p.p_type ~= "evaluate" and p.p_type ~= "property" -- depends on the preconditions of another option and p.p_type ~= "other" diff --git a/custom_functions_you_can_override.lua b/custom_functions_you_can_override.lua index 95b6594..1da66ad 100644 --- a/custom_functions_you_can_override.lua +++ b/custom_functions_you_can_override.lua @@ -96,7 +96,7 @@ yl_speak_up.custom_server_functions.precondition_eval = function(player, descr, end --- a custom precondition; still works, but less useful than the above method. +-- Custom preconditions are deprecated. -- Please use -- yl_speak_up.custom_server_functions.precondition_descriptions = {..} -- and @@ -104,12 +104,6 @@ end -- instead! -- has to return either true (=precondition is fulfilled) or false (=precondition is not fulfilled) -- 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.", } +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 -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", description = "Set a variable to a random number.", 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?", } -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", description = "Set a variable to a random value from a list.", 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: yl_speak_up.custom_functions_r_[ "example function" ] = { function_call = "yl_speak_up.custom_example_function", diff --git a/exec_eval_preconditions.lua b/exec_eval_preconditions.lua index 8ef70f3..9099a46 100644 --- a/exec_eval_preconditions.lua +++ b/exec_eval_preconditions.lua @@ -393,9 +393,6 @@ yl_speak_up.eval_precondition = function(player, n_id, p, other_options_true_or_ end -- all ok 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 -- are the preconditions of another option fulfilled? return (p.p_value diff --git a/fs_edit_preconditions.lua b/fs_edit_preconditions.lua index b9fd9e9..44c5b5a 100644 --- a/fs_edit_preconditions.lua +++ b/fs_edit_preconditions.lua @@ -60,9 +60,6 @@ -- a function ("function"): requires npc_master to create and edit -- p_value the lua code to execute and evaulate -- --- a custom function ("custon"): --- p_value parameter for the custom function --- -- depends on another option: -- p_value name of the other option of this dialog that is considered -- p_fulfilled shall option p_value be true or false? @@ -84,7 +81,6 @@ local check_what = { "the inventory of a block somewhere", -- 7 "an item the player offered/gave to the NPC", -- 8 "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 "nothing - always true (useful for generic dialogs)", "nothing - always false (useful for temporally deactivating an option)", @@ -96,8 +92,6 @@ local values_what = {"", "state", "property", "evaluate", "block", "trade", "player_offered_item", -- "function" requires npc_master priv: "function", - -- custom function (does not require npc_master priv) - "custom", -- depends on the preconditions of another option "other", "true", "false"} @@ -327,8 +321,6 @@ yl_speak_up.show_precondition = function(p, pname) else return "The player offered "..tostring(match).." of \""..tostring(item).."\"." end - elseif(p.p_type == "custom") then - return "Call custom function with param: \""..tostring(p.p_value).."\"." elseif(p.p_type == "other") then local fulfilled = "fulfilled" if(not(p.p_fulfilled) or p.p_fulfilled ~= "true") then