forked from your-land-mirror/yl_speak_up
removed precondition operator true_for_param and false_for_param because that can be better handled by precondition evaluate
This commit is contained in:
parent
1e828a1792
commit
3882c6263e
@ -59,7 +59,6 @@ end
|
||||
yl_speak_up.custom_server_functions.precondition_descriptions = {
|
||||
"(internal) hour of ingame day",
|
||||
"(internal) player's health points",
|
||||
"(internal) player has priv:",
|
||||
}
|
||||
|
||||
-- please return a useful value depending on the function;
|
||||
@ -83,20 +82,6 @@ yl_speak_up.custom_server_functions.precondition_eval = function(player, descr,
|
||||
elseif(descr == "(internal) player's health points") then
|
||||
return player:get_hp()
|
||||
|
||||
-- this is something that is better handled by a custom precondition
|
||||
-- with a parameter (see below - preconditions of type "evaluate"!)
|
||||
elseif(descr == "(internal) player has priv:") then
|
||||
-- the name of the priv is derived from the parameter
|
||||
local ret = minetest.check_player_privs(player,
|
||||
minetest.string_to_privs(tostring(precondition.p_var_cmp_value)))
|
||||
-- evaluate the parameter directly
|
||||
if(not(ret) or precondition.p_operator == "true_for_param"
|
||||
or precondition.p_operator == "false_for_param") then
|
||||
return ret
|
||||
end
|
||||
-- return the parameter for == / != comparison
|
||||
return tostring(precondition.p_var_cmp_value)
|
||||
|
||||
-- if this custom server function does not exist: return false
|
||||
else
|
||||
return false
|
||||
@ -262,6 +247,19 @@ yl_speak_up.custom_functions_p_[ "get_xp_of_player" ] = {
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
yl_speak_up.custom_functions_p_[ "check_if_player_has_priv" ] = {
|
||||
description = "Check if the player has a given priv.",
|
||||
param1_text = "Priv to check for:",
|
||||
param1_desc = "Checks if the player has the priv you entered here.",
|
||||
code = function(player, n_id, p)
|
||||
-- the name of the priv is derived from the parameter
|
||||
return minetest.check_player_privs(player,
|
||||
minetest.string_to_privs(tostring(p.p_param1 or "")))
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
-- TODO: actually implement these as examples
|
||||
yl_speak_up.custom_functions_p_[ "compare_variable_against_variable" ] = {
|
||||
description = "Compare a variable against another variable.",
|
||||
|
@ -149,14 +149,12 @@ local check_operator = {
|
||||
"less than x seconds ago", -- 12
|
||||
"has completed quest step", -- 13
|
||||
"quest step *not* completed", -- 14
|
||||
"is true for parameter:", -- 15
|
||||
"is false for parameter:", -- 16
|
||||
}
|
||||
|
||||
-- how to store these as p_value (the actual variable is stored in p_variable, and the value in p_cmp_value):
|
||||
local values_operator = {"", "==", "~=", ">=", ">", "<=", "<", "not", "is_set", "is_unset",
|
||||
"more_than_x_seconds_ago","less_than_x_seconds_ago",
|
||||
"quest_step_done", "quest_step_not_done", "true_for_param", "false_for_param"}
|
||||
"quest_step_done", "quest_step_not_done"}
|
||||
|
||||
|
||||
|
||||
@ -221,12 +219,6 @@ yl_speak_up.show_precondition = function(p, pname)
|
||||
elseif(p.p_operator == "quest_step_not_done") then
|
||||
return var_name.." shows: player has not yet completed quest step \""..
|
||||
tostring(p.p_var_cmp_value).."\""
|
||||
elseif(p.p_operator == "true_for_param") then
|
||||
return var_name.." is true if called with parameter: \""..
|
||||
tostring(p.p_var_cmp_value).."\""
|
||||
elseif(p.p_operator == "false_for_param") then
|
||||
return var_name.." is false if called with parameter: \""..
|
||||
tostring(p.p_var_cmp_value).."\""
|
||||
end
|
||||
if(p.p_var_cmp_value == "") then
|
||||
return var_name.." "..tostring(p.p_operator).." \"\""
|
||||
|
Loading…
Reference in New Issue
Block a user