From 7d84f6927837bcc5e414fe94019d39184b32d739 Mon Sep 17 00:00:00 2001 From: dtw Date: Fri, 13 Mar 2020 13:00:02 +0000 Subject: [PATCH 1/3] Change color of recommended action Just to make it stand out more in the log. --- addons/boxdestroyer/boxdestroyer.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/boxdestroyer/boxdestroyer.lua b/addons/boxdestroyer/boxdestroyer.lua index a75e02556..0d0f7dbda 100644 --- a/addons/boxdestroyer/boxdestroyer.lua +++ b/addons/boxdestroyer/boxdestroyer.lua @@ -67,6 +67,10 @@ observed_default = { thief_tools = {[1022] = true} +-- color codes for ease of use +txt = {} +txt[36] = string.char(31,36) -- yellow + -- global variables box = {} @@ -285,9 +289,9 @@ function display(id, chances) windower.add_to_chat(207, 'best guess: %d (%d%%)':format(box[id][math.ceil(#box[id] / 2)], 1 / remaining * 100)) local clue_value,guess_value = calculate_odds(id,chances) if clue_value > guess_value and remaining ~= 1 then - windower.add_to_chat(207, 'boxdestroyer recommends examining the chest') + windower.add_to_chat(207, 'boxdestroyer recommends'..txt[36]..' examining the chest') else - windower.add_to_chat(207, 'boxdestroyer recommends guessing %d':format(box[id][math.ceil(#box[id] / 2)])) + windower.add_to_chat(207, 'boxdestroyer recommends guessing'..txt[36]..' %d':format(box[id][math.ceil(#box[id] / 2)])) end end From e6b880d3d6fcaf2f9eaf0063cdd447c4471eb1cd Mon Sep 17 00:00:00 2001 From: dtw Date: Fri, 13 Mar 2020 13:01:00 +0000 Subject: [PATCH 2/3] Capitalize chat msgs Because OCD --- addons/boxdestroyer/boxdestroyer.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/boxdestroyer/boxdestroyer.lua b/addons/boxdestroyer/boxdestroyer.lua index 0d0f7dbda..3c5802cd2 100644 --- a/addons/boxdestroyer/boxdestroyer.lua +++ b/addons/boxdestroyer/boxdestroyer.lua @@ -261,9 +261,9 @@ end function display(id, chances) if #box[id] == 90 then - windower.add_to_chat(207, 'possible combinations: 10~99') + windower.add_to_chat(207, 'Possible combinations: 10~99') else - windower.add_to_chat(207, 'possible combinations: ' .. table.concat(box[id], ' ')) + windower.add_to_chat(207, 'Possible combinations: ' .. table.concat(box[id], ' ')) end local remaining = math.floor(#box[id] / math.pow(2, (chances - 1))) if remaining == 0 then @@ -277,13 +277,13 @@ function display(id, chances) local printed = false for _,v in pairs(box[id]) do if math.floor(v/10) == v%10 then - windower.add_to_chat(207, 'best guess: %d (%d%%)':format(v, 1 / remaining * 100)) + windower.add_to_chat(207, 'Best guess: %d (%d%%)':format(v, 1 / remaining * 100)) printed = true break end end if not printed then - windower.add_to_chat(207, 'best guess: %d (%d%%)':format(box[id][math.ceil(#box[id] / 2)], 1 / remaining * 100)) + windower.add_to_chat(207, 'Best guess: %d (%d%%)':format(box[id][math.ceil(#box[id] / 2)], 1 / remaining * 100)) end else windower.add_to_chat(207, 'best guess: %d (%d%%)':format(box[id][math.ceil(#box[id] / 2)], 1 / remaining * 100)) From 91251f0d498bcbf129441cadc951c1967b4051a2 Mon Sep 17 00:00:00 2001 From: dtw Date: Fri, 13 Mar 2020 14:44:52 +0000 Subject: [PATCH 3/3] Add suggested amends --- addons/boxdestroyer/boxdestroyer.lua | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/addons/boxdestroyer/boxdestroyer.lua b/addons/boxdestroyer/boxdestroyer.lua index 3c5802cd2..33e68064a 100644 --- a/addons/boxdestroyer/boxdestroyer.lua +++ b/addons/boxdestroyer/boxdestroyer.lua @@ -36,11 +36,20 @@ _addon.author = 'Seth VanHeulen (Acacia@Odin)' require('pack') require('tables') +require('chat') -- load message constants require('messages') +-- config + +config = require('config') +defaults = { + HighlightResult: false, + HighlightColor: 36, +} + -- global constants default = { @@ -67,10 +76,6 @@ observed_default = { thief_tools = {[1022] = true} --- color codes for ease of use -txt = {} -txt[36] = string.char(31,36) -- yellow - -- global variables box = {} @@ -288,11 +293,9 @@ function display(id, chances) else windower.add_to_chat(207, 'best guess: %d (%d%%)':format(box[id][math.ceil(#box[id] / 2)], 1 / remaining * 100)) local clue_value,guess_value = calculate_odds(id,chances) - if clue_value > guess_value and remaining ~= 1 then - windower.add_to_chat(207, 'boxdestroyer recommends'..txt[36]..' examining the chest') - else - windower.add_to_chat(207, 'boxdestroyer recommends guessing'..txt[36]..' %d':format(box[id][math.ceil(#box[id] / 2)])) - end + local result = clue_value > guess_value and remaining ~= 1 and 'examining the chest' or 'guessing ' .. '%d':format(box[id][math.ceil(#box[id] / 2)]) + local formatted_result = settings.HighlightResult and result:color(settings.HighlightColor) or result + windower.add_to_chat(207, 'boxdestroyer recommends ' .. formatted_result .. '.') end end