forked from your-land-mirror/yl_speak_up
fixed bug; effects are executed again
This commit is contained in:
parent
4085e87f29
commit
fd177472c5
@ -137,12 +137,13 @@ yl_speak_up.execute_next_action = function(player, a_id, result_of_a_id)
|
||||
and dialog.n_dialogs
|
||||
and dialog.n_dialogs[d_id]
|
||||
and dialog.n_dialogs[d_id].d_options
|
||||
and dialog.n_dialogs[d_id].d_options[o_id]
|
||||
and dialog.n_dialogs[d_id].d_options[o_id].actions) then
|
||||
and dialog.n_dialogs[d_id].d_options[o_id]) then
|
||||
-- get the actual actions
|
||||
actions = dialog.n_dialogs[d_id].d_options[o_id].actions
|
||||
-- needed later on when all actions are executed
|
||||
effects = dialog.n_dialogs[d_id].d_options[o_id].o_results
|
||||
end
|
||||
if(actions) then
|
||||
-- sort the actions so that we can execute them always in the
|
||||
-- same order
|
||||
sorted_key_list = yl_speak_up.sort_keys(actions)
|
||||
@ -194,9 +195,15 @@ yl_speak_up.execute_next_action = function(player, a_id, result_of_a_id)
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, "All actions have been executed successfully. "..
|
||||
"Doing effects/results now.")
|
||||
-- execute all effects/results
|
||||
local effects = dialog.n_dialogs[d_id].d_options[o_id].o_results
|
||||
local target_dialog = yl_speak_up.execute_all_relevant_effects(player, effects, o_id, true)
|
||||
yl_speak_up.speak_to[pname].o_id = nil
|
||||
yl_speak_up.speak_to[pname].a_id = nil
|
||||
if(not(target_dialog)
|
||||
or target_dialog == ""
|
||||
or not(dialog.n_dialogs[target_dialog])) then
|
||||
target_dialog = d_id
|
||||
end
|
||||
-- the function above returns a target dialog; show that to the player
|
||||
yl_speak_up.show_fs(player, "talk", {n_id = n_id, d_id = target_dialog})
|
||||
end
|
||||
@ -628,7 +635,7 @@ yl_speak_up.get_fs_action_custom = function(player, param)
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
return "size[8.5,4.0]"..
|
||||
"button[0.2,0.0;2.0,0.9;back_to_talk;Back to talk]"..
|
||||
"button[4.75,1.6;3.0,0.9;finished_action;Stare back]"..
|
||||
"button[4.75,0.0;3.0,0.9;finished_action;Stare back]"..
|
||||
|
||||
"tooltip[back_to_talk;Click here if you want the action to FAIL.]"..
|
||||
"tooltip[finished_action;Click here if you want the action to be a SUCCESS.]"..
|
||||
|
@ -216,14 +216,18 @@ yl_speak_up.execute_all_relevant_effects = function(player, effects, o_id, actio
|
||||
local pname = player:get_player_name()
|
||||
local n_id = yl_speak_up.speak_to[pname].n_id
|
||||
local edit_mode = (yl_speak_up.edit_mode[pname] == n_id)
|
||||
if(not(edit_mode)) then
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, "Executing effects.")
|
||||
-- Important: the list of effects is *sorted* here. The order remains constant!
|
||||
local sorted_key_list = yl_speak_up.sort_keys(effects)
|
||||
if(not(sorted_key_list) or #sorted_key_list < 1) then
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, "Error: No effects found. At least one of "..
|
||||
"type \"dialog\" is necessary.")
|
||||
elseif(not(edit_mode)) then
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, "Executing effects: "..
|
||||
table.concat(sorted_key_list, ", ")..".")
|
||||
else
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, "Not executing effects because in edit mode.")
|
||||
end
|
||||
local last_result = action_was_successful
|
||||
-- Important: the list of effects is *sorted* here. The order remains constant!
|
||||
local sorted_key_list = yl_speak_up.sort_keys(effects)
|
||||
local res = true
|
||||
for i, k in ipairs(sorted_key_list) do
|
||||
local r = effects[ k ]
|
||||
@ -231,11 +235,16 @@ yl_speak_up.execute_all_relevant_effects = function(player, effects, o_id, actio
|
||||
tostring(r.r_id)..": "..yl_speak_up.show_effect(r))
|
||||
-- do not execute effects in edit mode
|
||||
if(not(edit_mode)) then
|
||||
yl_speak_up.debug_msg(player, n_id, o_id,
|
||||
"Executing effect "..tostring(r.r_id)..".")
|
||||
res = yl_speak_up.execute_effect(player, n_id, o_id, r)
|
||||
if(not(res)) then
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, tostring(r.r_id)..
|
||||
" -> Effect failed to execute.")
|
||||
end
|
||||
else
|
||||
-- in edit mode: assume that the effect was successful
|
||||
res = true
|
||||
end
|
||||
-- "dialog" gives us the normal target_dialog
|
||||
if(r.r_type and r.r_type == "dialog") then
|
||||
|
Loading…
Reference in New Issue
Block a user