added effect state change of variable

This commit is contained in:
Sokomine 2021-06-12 01:07:08 +02:00
parent 003b322af3
commit b60d5b03d0
2 changed files with 29 additions and 1 deletions

View File

@ -360,7 +360,27 @@ yl_speak_up.execute_effect = function(player, n_id, o_id, r)
-- "an internal state (i.e. of a quest)", -- 2
elseif(r.r_type == "state") then
-- TODO: implement effect "state"
if(not(r.r_variable) or r.r_variable == "") then
return false
end
local pname = player:get_player_name()
local owner = yl_speak_up.npc_owner[ n_id ]
-- set the value of the variable
local new_value = nil
if( r.r_operator and r.r_operator == "set_to") then
new_value = r.r_var_cmp_value
elseif(r.r_operator and r.r_operator == "unset") then
new_value = nil
else
yl_speak_up.debug_msg(player, n_id, o_id, tostring(r.r_id).." "..
"state: Unsupported type: "..tostring(r.r_value)..".")
return false
end
local ret = yl_speak_up.set_quest_variable_value(owner, pname, r.r_variable, new_value)
yl_speak_up.debug_msg(player, n_id, o_id, tostring(r.r_id).." "..
"state: Success: "..tostring(ret).." for setting "..tostring(r.r_variable).." to "..
tostring(new_value)..".")
return ret
-- "a block somewhere" -- 3
elseif(r.r_type == "block") then
-- is the position given correctly?

View File

@ -3,6 +3,14 @@
yl_speak_up.player_vars = {}
-- set the value of a variable used by a player in an NPC
yl_speak_up.set_quest_variable_value = function(owner_name, current_player_name, variable_name, new_value)
-- TODO: actually implement
minetest.chat_send_player(current_player_name, "[Info] Trying to set variable "..
tostring(variable_name).." to "..tostring(new_value)..".")
return false
end
-- get the value of a variable used by a player in an NPC
yl_speak_up.get_quest_variable_value = function(owner_name, current_player_name, variable_name)
-- TODO: actually implement