added missing effects for variable states
This commit is contained in:
parent
bea29aed26
commit
7a0c442508
@ -79,13 +79,19 @@ local values_block = {"", "place", "dig", "punch", "right-click"}
|
||||
-- comparison operators for variables
|
||||
local check_operator = {
|
||||
"- please select -", -- 1
|
||||
"set to value:", -- 2
|
||||
"is no longer needed (unset)", -- 3
|
||||
"set to current time", -- 4
|
||||
"new value:", -- 2
|
||||
"discard/unset/forget", -- 3
|
||||
"current time", -- 4
|
||||
"quest step completed:", -- 5
|
||||
minetest.formspec_escape("max(current, new_value)"), -- 6
|
||||
minetest.formspec_escape("min(current, new_value)"), -- 7
|
||||
"increment by:", -- 8
|
||||
"decrement by:", -- 9
|
||||
}
|
||||
|
||||
-- how to store these as r_value (the actual variable is stored in r_variable, and the value in r_new_value):
|
||||
local values_operator = {"", "set_to", "unset", "set_to_current_time"}
|
||||
local values_operator = {"", "set_to", "unset", "set_to_current_time",
|
||||
"quest_step", "maximum", "minimum", "increment", "decrement"}
|
||||
|
||||
|
||||
-- get the list of variables the player has *write* access to
|
||||
@ -152,6 +158,21 @@ yl_speak_up.show_effect = function(r, pname)
|
||||
return "discard "..var_name.." (unset)"
|
||||
elseif(r.r_operator == "set_to_current_time") then
|
||||
return "set "..var_name.." to the current time"
|
||||
elseif(r.r_operator == "quest_step") then
|
||||
return "store that the player has completed quest step \""..
|
||||
tostring(r.r_var_cmp_value).."\""
|
||||
elseif(r.r_operator == "maximum") then
|
||||
return "set "..var_name.." to value \""..
|
||||
tostring(r.r_var_cmp_value).."\" if its current value is larger than that"
|
||||
elseif(r.r_operator == "minimum") then
|
||||
return "set "..var_name.." to value \""..
|
||||
tostring(r.r_var_cmp_value).."\" if its current value is lower than that"
|
||||
elseif(r.r_operator == "increment") then
|
||||
return "increment the value of "..var_name.." by \""..
|
||||
tostring(r.r_var_cmp_value).."\""
|
||||
elseif(r.r_operator == "decrement") then
|
||||
return "decrement the value of "..var_name.." by \""..
|
||||
tostring(r.r_var_cmp_value).."\""
|
||||
else
|
||||
return "ERROR: Wrong operator \""..tostring(r.r_operator).."\" for "..var_name
|
||||
end
|
||||
@ -429,6 +450,23 @@ yl_speak_up.execute_effect = function(player, n_id, o_id, r)
|
||||
-- we store the time in seconds - because microseconds would just
|
||||
-- confuse the users and be too fine grained anyway
|
||||
new_value = math.floor(minetest.get_us_time()/1000000)
|
||||
elseif(r.r_operator and r.r_operator == "quest_step") then
|
||||
-- quest_step and maximum are effectively the same
|
||||
-- TODO: later on, quest steps may be strings
|
||||
local var_val = yl_speak_up.get_quest_variable_value(pname, r.r_variable)
|
||||
new_value = math.max(var_val, r.r_var_cmp_value)
|
||||
elseif(r.r_operator and r.r_operator == "maximum") then
|
||||
local var_val = yl_speak_up.get_quest_variable_value(pname, r.r_variable)
|
||||
new_value = math.max(var_val, r.r_var_cmp_value)
|
||||
elseif(r.r_operator and r.r_operator == "minimum") then
|
||||
local var_val = yl_speak_up.get_quest_variable_value(pname, r.r_variable)
|
||||
new_value = math.min(var_val, r.r_var_cmp_value)
|
||||
elseif(r.r_operator and r.r_operator == "increment") then
|
||||
local var_val = yl_speak_up.get_quest_variable_value(pname, r.r_variable)
|
||||
new_value = var_val + r.r_var_cmp_value
|
||||
elseif(r.r_operator and r.r_operator == "decrement") then
|
||||
local var_val = yl_speak_up.get_quest_variable_value(pname, r.r_variable)
|
||||
new_value = var_val - r.r_var_cmp_value
|
||||
else
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, tostring(r.r_id).." "..
|
||||
"state: Unsupported type: "..tostring(r.r_value)..".")
|
||||
@ -728,7 +766,7 @@ yl_speak_up.get_fs_edit_effects = function(player, table_click_result)
|
||||
yl_speak_up.get_sorted_player_var_list_write_access,
|
||||
yl_speak_up.show_effect,
|
||||
"table_of_elements",
|
||||
"Change the value of the following variable:", "What to do:", "New value:",
|
||||
"Change the value of the following variable:", "Set variable to:", "New value:",
|
||||
"The NPC shall do something to the block at the following position:"
|
||||
)
|
||||
end
|
||||
|
@ -1142,7 +1142,7 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
||||
|
||||
local show_var_usage = ""
|
||||
if(x_id
|
||||
and elements
|
||||
|
||||
and elements[ x_id ]
|
||||
and elements[ x_id ][ id_prefix.."type"]
|
||||
and elements[ x_id ][ id_prefix.."type"] == "state"
|
||||
@ -1382,7 +1382,7 @@ yl_speak_up.get_fs_edit_option_p_and_e_state = function(
|
||||
data.operator = 1
|
||||
save_button = ""
|
||||
end
|
||||
local field_for_value = "field[11.2,4.8;7.0,0.6;var_cmp_value;;"..
|
||||
local field_for_value = "field[11.7,4.8;7.5,0.6;var_cmp_value;;"..
|
||||
minetest.formspec_escape(data.var_cmp_value or "- enter value -").."]"
|
||||
-- do not show value input field for unary operators
|
||||
-- (unary operators are diffrent for prerequirements and effects)
|
||||
@ -1390,7 +1390,7 @@ yl_speak_up.get_fs_edit_option_p_and_e_state = function(
|
||||
or (id_prefix == "p_" and (data.operator == 1 or (data.operator>=8 and data.operator<11)))
|
||||
-- "unset", "set_to_current_time"
|
||||
or (id_prefix == "r_" and (data.operator == 3 or data.operator == 4))) then
|
||||
field_for_value = "label[11.2,5.1;- not used for this operator -]"
|
||||
field_for_value = "label[11.7,5.1;- not used for this operator -]"
|
||||
end
|
||||
-- the list of available variables needs to be extended with the ones
|
||||
-- the player has read access to, and the order has to be constant
|
||||
@ -1402,10 +1402,10 @@ yl_speak_up.get_fs_edit_option_p_and_e_state = function(
|
||||
"- please select -"..var_list_stripped..";"..
|
||||
tostring(data.variable + 1)..";]"..
|
||||
"label[7.0,4.3;"..text_select_operator.."]"..
|
||||
"dropdown[7.0,4.8;4.0,0.6;select_operator;"..
|
||||
"dropdown[7.0,4.8;4.5,0.6;select_operator;"..
|
||||
table.concat(check_operator, ",")..";"..
|
||||
tostring(data.operator)..";]"..
|
||||
"label[11.2,4.3;"..text_select_value.."]"..
|
||||
"label[11.7,4.3;"..text_select_value.."]"..
|
||||
field_for_value..
|
||||
"button[0.2,6.0;4.0,0.6;manage_variables;Manage variables]"..
|
||||
"button[4.7,6.0;6.5,0.6;show_var_usage_edit_element;Show where this variable is used]"..
|
||||
|
Loading…
Reference in New Issue
Block a user