mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-06-20 06:08:03 +02:00
added preconditions quest_step_done and quest_step_not_done
This commit is contained in:
parent
be9dfbf1dd
commit
586a18073e
@ -101,11 +101,14 @@ local check_operator = {
|
||||
"is_unset (has no value)", -- 10
|
||||
"more than x seconds ago", -- 11
|
||||
"less than x seconds ago", -- 12
|
||||
"has completed quest step", -- 13
|
||||
"quest step *not* completed", -- 14
|
||||
}
|
||||
|
||||
-- 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"}
|
||||
"more_than_x_seconds_ago","less_than_x_seconds_ago",
|
||||
"quest_step_done", "quest_step_not_done"}
|
||||
|
||||
-- some internal ones...
|
||||
local check_variable = {
|
||||
@ -166,6 +169,12 @@ yl_speak_up.show_precondition = function(p, pname)
|
||||
elseif(p.p_operator == "less_than_x_seconds_ago") then
|
||||
return var_name.." was set to current time "..
|
||||
"*less* than "..tostring(p.p_var_cmp_value).." seconds ago"
|
||||
elseif(p.p_operator == "quest_step_done") then
|
||||
return var_name.." shows: player completed quest step \""..
|
||||
tostring(p.p_var_cmp_value).."\" successfully"
|
||||
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).."\""
|
||||
end
|
||||
if(p.p_var_cmp_value == "") then
|
||||
return var_name.." "..tostring(p.p_operator).." \"\""
|
||||
@ -353,6 +362,32 @@ yl_speak_up.eval_precondition = function(player, n_id, p)
|
||||
end
|
||||
return (tonumber(var_val) + tonumber(p.p_var_cmp_value)) >
|
||||
minetest.get_us_time()/1000000
|
||||
-- this is currently equivalent to >= but may change in the future
|
||||
-- TODO: quest steps may be strings in the future
|
||||
elseif(p.p_operator == "quest_step_done") then
|
||||
if(p.p_var_cmp_value == nil) then
|
||||
return false
|
||||
end
|
||||
-- compare numeric if possible
|
||||
if(tonumber(var_val) and tonumber(p.p_var_cmp_value)) then
|
||||
return tonumber(var_val) >= tonumber(p.p_var_cmp_value)
|
||||
-- fallback: compare as strings
|
||||
else
|
||||
return tostring(var_val) >= tostring(p.p_var_cmp_value)
|
||||
end
|
||||
-- this is currently equivalent to < but may change in the future
|
||||
-- TODO: quest steps may be strings in the future
|
||||
elseif(p.p_operator < "quest_step_not_done") then
|
||||
-- if the variable is not set at all, then the quest step definitely
|
||||
-- has not been reached yet
|
||||
if(p.p_var_cmp_value == nil) then
|
||||
return true
|
||||
end
|
||||
if(tonumber(var_val) and tonumber(p.p_var_cmp_value)) then
|
||||
return tonumber(var_val) < tonumber(p.p_var_cmp_value)
|
||||
else
|
||||
return tostring(var_val) < tostring(p.p_var_cmp_value)
|
||||
end
|
||||
end
|
||||
-- unsupported operator
|
||||
return false
|
||||
|
Loading…
Reference in New Issue
Block a user