forked from Sokomine/yl_speak_up
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 "..
|
yl_speak_up.debug_msg(player, n_id, o_id, "Action "..
|
||||||
tostring(a_id).." failed. Switching to dialog "..
|
tostring(a_id).." failed. Switching to dialog "..
|
||||||
tostring(this_action.a_on_failure)..".")
|
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].d_id = this_action.a_on_failure
|
||||||
yl_speak_up.speak_to[pname].o_id = nil
|
yl_speak_up.speak_to[pname].o_id = nil
|
||||||
yl_speak_up.speak_to[pname].a_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,
|
d_id = this_action.a_on_failure,
|
||||||
alternate_text = this_action.alternate_text})
|
alternate_text = this_action.alternate_text})
|
||||||
return
|
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
|
||||||
end
|
end
|
||||||
-- get the next entry
|
-- 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)..
|
yl_speak_up.debug_msg(player, n_id, o_id, "Action "..tostring(a.a_id)..
|
||||||
": Wrong item given. Got: "..stack:to_string()..
|
": Wrong item given. Got: "..stack:to_string()..
|
||||||
" Expected: "..tostring(a.a_value)..".")
|
" 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
|
return false
|
||||||
end
|
end
|
||||||
local meta = stack:get_meta()
|
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
|
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)..
|
yl_speak_up.debug_msg(player, n_id, o_id, "Action "..tostring(a.a_id)..
|
||||||
": Wrong quest item (wrong 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
|
return false
|
||||||
end
|
end
|
||||||
-- was this quest item given to another player?
|
-- 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 "..
|
": Quest item was given to "..
|
||||||
tostring(meta:get_string("yl_speak_up:quest_item_for"))..
|
tostring(meta:get_string("yl_speak_up:quest_item_for"))..
|
||||||
", but "..tostring(pname).." gave it.")
|
", 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
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -639,10 +664,25 @@ yl_speak_up.input_fs_action_text_input = function(player, formname, fields)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
if(fields.finished_action and fields.quest_answer and fields.quest_answer ~= "") then
|
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?
|
-- is the answer correct?
|
||||||
-- strip leading and tailing blanks
|
-- strip leading and tailing blanks
|
||||||
local success = not(not(fields.quest_answer and a.a_value
|
local success = not(not(fields.quest_answer and a.a_value
|
||||||
and fields.quest_answer:trim() == a.a_value:trim()))
|
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
|
-- the action was a either a success or failure
|
||||||
yl_speak_up.execute_next_action(player, a_id, success)
|
yl_speak_up.execute_next_action(player, a_id, success)
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user