added logging for failed and successful actions
This commit is contained in:
parent
8f1773fbd7
commit
6befa8f10a
@ -210,6 +210,10 @@ yl_speak_up.execute_next_action = function(player, a_id, result_of_a_id)
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, "Action "..
|
||||
tostring(a_id).." failed. Switching to dialog "..
|
||||
tostring(this_action.a_on_failure)..".")
|
||||
yl_speak_up.log_change(pname, n_id,
|
||||
"Player failed to complete action "..tostring(a_id)..
|
||||
" of "..tostring(o_id).." of "..tostring(d_id)..": "..
|
||||
tostring(this_action.a_value)..".")
|
||||
yl_speak_up.speak_to[pname].d_id = this_action.a_on_failure
|
||||
yl_speak_up.speak_to[pname].o_id = nil
|
||||
yl_speak_up.speak_to[pname].a_id = nil
|
||||
@ -217,6 +221,10 @@ yl_speak_up.execute_next_action = function(player, a_id, result_of_a_id)
|
||||
d_id = this_action.a_on_failure,
|
||||
alternate_text = this_action.alternate_text})
|
||||
return
|
||||
else
|
||||
yl_speak_up.log_change(pname, n_id,
|
||||
"Player completed action "..tostring(a_id)..
|
||||
" of "..tostring(o_id).." of "..tostring(d_id)..".")
|
||||
end
|
||||
end
|
||||
-- get the next entry
|
||||
@ -394,6 +402,12 @@ yl_speak_up.action_quest_item_check = function(player)
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, "Action "..tostring(a.a_id)..
|
||||
": Wrong item given. Got: "..stack:to_string()..
|
||||
" Expected: "..tostring(a.a_value)..".")
|
||||
yl_speak_up.log_change(pname, n_id,
|
||||
"Action "..tostring(a_id)..
|
||||
" of "..tostring(yl_speak_up.speak_to[pname].o_id)..
|
||||
" of "..tostring(yl_speak_up.speak_to[pname].d_id)..
|
||||
"failed: Player gave item \""..tostring(cmp).."\", but we wanted: \""..
|
||||
tostring(a.a_value).."\".")
|
||||
return false
|
||||
end
|
||||
local meta = stack:get_meta()
|
||||
@ -404,6 +418,11 @@ yl_speak_up.action_quest_item_check = function(player)
|
||||
if(meta:get_string("yl_speak_up:quest_id") ~= a.a_item_quest_id) then
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, "Action "..tostring(a.a_id)..
|
||||
": Wrong quest item (wrong ID).")
|
||||
yl_speak_up.log_change(pname, n_id,
|
||||
"Action "..tostring(a_id)..
|
||||
" of "..tostring(yl_speak_up.speak_to[pname].o_id)..
|
||||
" of "..tostring(yl_speak_up.speak_to[pname].d_id)..
|
||||
"failed: Player gave wrong quest item (wrong ID).")
|
||||
return false
|
||||
end
|
||||
-- was this quest item given to another player?
|
||||
@ -412,6 +431,12 @@ yl_speak_up.action_quest_item_check = function(player)
|
||||
": Quest item was given to "..
|
||||
tostring(meta:get_string("yl_speak_up:quest_item_for"))..
|
||||
", but "..tostring(pname).." gave it.")
|
||||
yl_speak_up.log_change(pname, n_id,
|
||||
"Action "..tostring(a_id)..
|
||||
" of "..tostring(yl_speak_up.speak_to[pname].o_id)..
|
||||
" of "..tostring(yl_speak_up.speak_to[pname].d_id)..
|
||||
"failed: Player gave quest item that belonged to player "..
|
||||
tostring(meta:get_string("yl_speak_up:quest_item_for"))..".")
|
||||
return false
|
||||
end
|
||||
end
|
||||
@ -639,10 +664,25 @@ yl_speak_up.input_fs_action_text_input = function(player, formname, fields)
|
||||
return
|
||||
end
|
||||
if(fields.finished_action and fields.quest_answer and fields.quest_answer ~= "") then
|
||||
local n_id = yl_speak_up.speak_to[pname].n_id
|
||||
-- is the answer correct?
|
||||
-- strip leading and tailing blanks
|
||||
local success = not(not(fields.quest_answer and a.a_value
|
||||
and fields.quest_answer:trim() == a.a_value:trim()))
|
||||
if(not(success)) then
|
||||
yl_speak_up.log_change(pname, n_id,
|
||||
"Action "..tostring(a_id)..
|
||||
" of "..tostring(yl_speak_up.speak_to[pname].o_id)..
|
||||
" of "..tostring(yl_speak_up.speak_to[pname].d_id)..
|
||||
": Player answered with \""..tostring(fields.quest_answer:trim())..
|
||||
"\", but we expected: \""..tostring(a.a_value:trim()).."\".")
|
||||
else
|
||||
yl_speak_up.log_change(pname, n_id,
|
||||
"Action "..tostring(a_id)..
|
||||
" of "..tostring(yl_speak_up.speak_to[pname].o_id)..
|
||||
" of "..tostring(yl_speak_up.speak_to[pname].d_id)..
|
||||
": Answer is correct.")
|
||||
end
|
||||
-- the action was a either a success or failure
|
||||
yl_speak_up.execute_next_action(player, a_id, success)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user