From 405bf0990a4efea2ff24030b25ce27006facd511 Mon Sep 17 00:00:00 2001 From: aragan <64033062+aragan@users.noreply.github.com> Date: Sun, 14 Dec 2025 21:41:23 +0300 Subject: [PATCH 1/2] [rollracker] Update version and enhance HUD features Updated version and author information, added HUD functionality for displaying roll information, and improved command handling. --- addons/rolltracker/rolltracker.lua | 180 +++++++++++++++-------------- 1 file changed, 92 insertions(+), 88 deletions(-) diff --git a/addons/rolltracker/rolltracker.lua b/addons/rolltracker/rolltracker.lua index d80e68957..a5c24ec5b 100644 --- a/addons/rolltracker/rolltracker.lua +++ b/addons/rolltracker/rolltracker.lua @@ -25,91 +25,92 @@ --SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. _addon.name = 'RollTracker' -_addon.version = '1.8.1.1' -_addon.author = 'Balloon' +_addon.version = '1.9.0.0' +_addon.author = 'Balloon, Aragan' _addon.commands = {'rolltracker','rt'} +_addon.update = 'update by Aurthor Aragan 2024' require('luau') chat = require('chat') chars = require('chat.chars') packets = require('packets') +local texts = require('texts') + + +-- RollTracker HUD settings (custom HUD for rolls) +local rt_hud = texts.new() -- Create a new text object for the HUD +local rt_hud_visible = false -- Boolean to track if the HUD is currently visible +local rt_hud_timestamp = 0 -- Timestamp to track when the HUD was last shown +local rt_hud_duration = 50 -- Duration (in seconds) to show the HUD + +-- Function to initialize the HUD settings +local function rt_init_hud() + rt_hud:pos(900, 300) -- Set the position of the HUD on the screen (x=900, y=300) + rt_hud:bg_color(0, 0, 0) -- Set the background color of the HUD to black (RGB: 0, 0, 0) + rt_hud:bg_alpha(80) -- Set the background transparency (alpha) to 80 (out of 255) + rt_hud:color(255, 255, 255) -- Set the text color to white (RGB: 255, 255, 255) + rt_hud:font('Arial') -- Set the font of the text to Arial + rt_hud:size(12) -- Set the font size to 12 + rt_hud:hide() -- Initially hide the HUD +end + +-- Function to display the HUD with a message +local function rt_show_hud(msg) + rt_hud:text(msg) -- Set the text of the HUD to the provided message + rt_hud:show() -- Show the HUD on the screen + rt_hud_visible = true -- Mark the HUD as visible + rt_hud_timestamp = os.time() -- Record the current time as the timestamp +end + +windower.register_event('load', function() + rt_init_hud() +end) + +windower.register_event('prerender', function() + if rt_hud_visible and os.time() - rt_hud_timestamp >= rt_hud_duration then + rt_hud:hide() + rt_hud_visible = false + end +end) + + + + defaults = {} defaults.autostopper = true defaults.bust = 1 defaults.effected = 1 defaults.fold = 1 defaults.luckyinfo = true -defaults.channel = {} -defaults.channel.roll = 1 -- This should be 101, but the current default is 1 -defaults.channel.warn = 1 -defaults.color = {} -defaults.color.bonus = 13 -defaults.color.lucky = 158 -defaults.color.warn = 159 -defaults.color.unlucky = 167 settings = config.load(defaults) windower.register_event('addon command',function (...) cmd = {...} - local command = ((cmd[1] ~= nil) and cmd[1]:lower()) or "help" - - if command == "autostop" then - if settings.autostopper then - settings.autostopper = false - log('Will no longer stop Double-UP on a Lucky Roll.') - else - settings.autostopper = true - log('Will stop Double-UP on a Lucky Roll.') - end - elseif command == "luckyinfo" then - if settings.luckyinfo then - settings.luckyinfo = false - log('Lucky/Unlucky Info will no longer be displayed.') - else - settings.luckyinfo = true - log('Lucky/Unlucky Info will now be displayed.') - end - elseif command == "channel" then - local subcommand = ((cmd[2] ~= nil) and cmd[2]:lower()) or "help" - if subcommand == "help" then - log('Chat Channels: roll(' .. settings.channel.roll .. '), warn(' .. settings.channel.warn .. ')') - return - end - if settings.channel[subcommand] == nil then - log('Valid chat channels are: roll and warn') - return - end - local channel = tonumber(((cmd[3] ~= nil) and cmd[3]) or 0) - if (channel == nil) or (channel < 1) or (channel > 255) then - log('Valid channnel values are 1 through 255') - return - end - settings.channel[subcommand] = channel - log('Chat Channel set to ' .. channel) - elseif command == "color" then - local subcommand = ((cmd[2] ~= nil) and cmd[2]:lower()) or "help" - if subcommand == "help" then - log('Colors: bonus(' .. settings.color.bonus .. '), lucky(' .. settings.color.lucky .. '), unlucky(' .. settings.color.unlucky .. '), warn(' .. settings.color.warn .. ')') - return - end - if settings.color[subcommand] == nil then - log('Valid color types are: roll, bonus, lucky, unlucky, and warn') - return - end - local color = tonumber(((cmd[3] ~= nil) and cmd[3]) or 0) - if (color == nil) or (color < 1) or (color > 255) then - log('Valid color values are 1 through 255') - return + if cmd[1] ~= nil then + if cmd[1]:lower() == "help" then + log('To toggle rolltracker from allowing/stopping rolls type: //rolltracker autostop') + log('To toggle rolltracker from showing/hiding Lucky Info type: //rolltracker luckyinfo') + elseif cmd[1]:lower() == "autostop" then + if settings.autostopper then + settings.autostopper = false + log('Will no longer stop Double-UP on a Lucky Roll.') + else + settings.autostopper = true + log('Will stop Double-UP on a Lucky Roll.') + end + elseif cmd[1]:lower() == "luckyinfo" then + if settings.luckyinfo then + settings.luckyinfo = false + log('Lucky/Unlucky Info will no longer be displayed.') + else + settings.luckyinfo = true + log('Lucky/Unlucky Info will now be displayed.') + end end - settings.color[subcommand] = color - log('Color for \'' .. subcommand .. '\' set to ' .. color) - else - printHelp() - return + config.save(settings, 'all') end - config.save(settings, 'all') end) --This is done because GearSwap swaps out too fast, and sometimes things aren't reported in memory. @@ -125,19 +126,6 @@ windower.register_event('incoming chunk', function(id, data) end end) -function printHelp() - log('rt autostop : Toggle allowing/stopping rolls') - log('rt luckyinfo : Toggle showing/hiding Lucky Info') - log('rt channel : Show current chat channels for rolltracker messages') - log('rt channel roll : Set the chat channel for rolls (1-255, ex. 101)') - log('rt channel warn : Set the chat channel for warnings (1-255, ex. 101)') - log('rt color : Show current color settings') - log('rt color bonus : Set the color for the Roll Bonus text (1-255, ex. 158)') - log('rt color lucky : Set the color for the Lucky text (1-255, ex. 158)') - log('rt color unlucky : Set the color for the Unlucky text (1-255, ex. 167)') - log('rt color warn : Set the color for warning messages (1-255, ex. 159)') -end - function getGear(slot) local equip = windower.ffxi.get_items()['equipment'] return windower.ffxi.get_items(equip[slot..'_bag'])[equip[slot]]~= nil and windower.ffxi.get_items(equip[slot..'_bag'])[equip[slot]].id or 0 @@ -264,19 +252,35 @@ windower.register_event('action', function(act) isLucky = false if rollNum == rollInfo[rollID][15] or rollNum == 11 then isLucky = true - windower.add_to_chat(settings.channel.roll, 'Lucky roll!':color(settings.color.lucky)) - luckChat = " (Lucky!)":color(settings.color.lucky) + windower.add_to_chat(158,'Lucky roll!') + luckChat = string.char(31,158).." (Lucky!)" elseif rollNum == rollInfo[rollID][16] then - luckChat = " (Unlucky!)":color(settings.color.unlucky) + luckChat = string.char(31,167).." (Unlucky!)" end + + -- HUD details (roll number + Lucky/Unlucky numbers) + local lucky_num = rollInfo[rollID][15] + local unlucky_num = rollInfo[rollID][16] + + local hud_lu = '' + if settings.luckyinfo then + hud_lu = string.format('\nLucky: %d Unlucky: %d', lucky_num, unlucky_num) + end + + local hud_status = '' + if rollNum == lucky_num or rollNum == 11 then + hud_status = ' (Lucky!)' + elseif rollNum == unlucky_num then + hud_status = ' (Unlucky!)' + end if rollNum == 12 and #rollMembers > 0 then - local bustchat = amountHit..'Bust! '..chat.controls.reset..chars.implies..' '..membersHit..' '..chars.implies..' ('..rollInfo[rollID][rollNum+1]..rollInfo[rollID][14]..')' - windower.add_to_chat(settings.channel.roll, bustchat:color(settings.color.bust)) + windower.add_to_chat(1, string.char(31,167)..amountHit..'Bust! '..chat.controls.reset..chars.implies..' '..membersHit..' '..chars.implies..' ('..rollInfo[rollID][rollNum+1]..rollInfo[rollID][14]..')') + rt_show_hud(string.format('%s Roll\nBust!%s', rollInfo[rollID][1], hud_lu)) else - local bonuschat = ' (+'..rollBonus..')' - windower.add_to_chat(settings.channel.roll, amountHit..membersHit..chat.controls.reset..' '..chars.implies..' '..rollInfo[rollID][1]..' Roll '..chars['circle' .. rollNum]..luckChat.. bonuschat:color(settings.color.bonus) ..BustRate(rollNum, rollActor)..ReportRollInfo(rollID, rollActor)) + windower.add_to_chat(1, amountHit..membersHit..chat.controls.reset..' '..chars.implies..' '..rollInfo[rollID][1]..' Roll '..chars['circle' .. rollNum]..luckChat..string.char(31,13)..' (+'..rollBonus..')'..BustRate(rollNum, rollActor)..ReportRollInfo(rollID, rollActor)) + rt_show_hud(string.format('%s Roll %d%s\n+%s%s', rollInfo[rollID][1], rollNum, hud_status, rollBonus, hud_lu)) end end end @@ -418,7 +422,7 @@ windower.register_event('outgoing text', function(original, modified) modified = original if cleaned:match('/jobability \"?Double.*Up') or cleaned:match('/ja \"?Double.*Up') then if isLucky and settings.autostopper and rollActor == player.id then - windower.add_to_chat(settings.channel.warn, 'Attempting to Doubleup on a Lucky Roll: Re-double up to continue.':color(settings.color.warn)) + windower.add_to_chat(159,'Attempting to Doubleup on a Lucky Roll: Re-double up to continue.') isLucky = false modified = "" end @@ -435,7 +439,7 @@ windower.register_event('outgoing text', function(original, modified) modified = cleaned ranMultiple = false else - windower.add_to_chat(settings.channel.warn, 'No \'Bust\'. Fold again to continue.':color(settings.color.warn)) + windower.add_to_chat(159, 'No \'Bust\'. Fold again to continue.') ranMultiple = true modified = "" end @@ -444,4 +448,4 @@ windower.register_event('outgoing text', function(original, modified) end return modified -end) \ No newline at end of file +end) From 3b68c58c9262f13dfd2cfe4cde899b60158c3f04 Mon Sep 17 00:00:00 2001 From: aragan <64033062+aragan@users.noreply.github.com> Date: Mon, 15 Dec 2025 02:10:05 +0300 Subject: [PATCH 2/2] Refactor HUD management and update version to 1.8.2.0 Updated version number and refactored HUD functions for better management and visibility. --- addons/rolltracker/rolltracker.lua | 182 ++++++++++++++++++++++------- 1 file changed, 143 insertions(+), 39 deletions(-) diff --git a/addons/rolltracker/rolltracker.lua b/addons/rolltracker/rolltracker.lua index a5c24ec5b..c06ddfecc 100644 --- a/addons/rolltracker/rolltracker.lua +++ b/addons/rolltracker/rolltracker.lua @@ -25,7 +25,7 @@ --SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. _addon.name = 'RollTracker' -_addon.version = '1.9.0.0' +_addon.version = '1.8.2.0' _addon.author = 'Balloon, Aragan' _addon.commands = {'rolltracker','rt'} _addon.update = 'update by Aurthor Aragan 2024' @@ -35,47 +35,74 @@ chat = require('chat') chars = require('chat.chars') packets = require('packets') -local texts = require('texts') - - --- RollTracker HUD settings (custom HUD for rolls) -local rt_hud = texts.new() -- Create a new text object for the HUD -local rt_hud_visible = false -- Boolean to track if the HUD is currently visible -local rt_hud_timestamp = 0 -- Timestamp to track when the HUD was last shown -local rt_hud_duration = 50 -- Duration (in seconds) to show the HUD +texts = require('texts') + +local hudText +local hudVisible = false +local hudTimestamp = 0 +local lastHudSave = 0 + +local function initHud() + if hudText then return end + hudText = texts.new({ + pos = {x = 900, y = 300}, + bg = {alpha = 80, red = 0, green = 0, blue = 0}, + text = {font = 'Arial', size = 12, alpha = 255, red = 255, green = 255, blue = 255}, + flags = {draggable = true}, + padding = 6, + }) + hudText:hide() +end --- Function to initialize the HUD settings -local function rt_init_hud() - rt_hud:pos(900, 300) -- Set the position of the HUD on the screen (x=900, y=300) - rt_hud:bg_color(0, 0, 0) -- Set the background color of the HUD to black (RGB: 0, 0, 0) - rt_hud:bg_alpha(80) -- Set the background transparency (alpha) to 80 (out of 255) - rt_hud:color(255, 255, 255) -- Set the text color to white (RGB: 255, 255, 255) - rt_hud:font('Arial') -- Set the font of the text to Arial - rt_hud:size(12) -- Set the font size to 12 - rt_hud:hide() -- Initially hide the HUD +local function applyHudSettings() + if not hudText or not settings then return end + hudText:pos(settings.hudX or 900, settings.hudY or 300) + pcall(function() hudText:draggable(settings.hudDrag ~= false) end) end --- Function to display the HUD with a message -local function rt_show_hud(msg) - rt_hud:text(msg) -- Set the text of the HUD to the provided message - rt_hud:show() -- Show the HUD on the screen - rt_hud_visible = true -- Mark the HUD as visible - rt_hud_timestamp = os.time() -- Record the current time as the timestamp +local function showHud(msg) + if not settings or not settings.hud then return end + initHud() + applyHudSettings() + hudText:text(msg) + hudText:show() + hudVisible = true + hudTimestamp = os.time() end -windower.register_event('load', function() - rt_init_hud() -end) +local function hideHud() + if hudText and hudVisible then + hudText:hide() + end + hudVisible = false +end windower.register_event('prerender', function() - if rt_hud_visible and os.time() - rt_hud_timestamp >= rt_hud_duration then - rt_hud:hide() - rt_hud_visible = false + if settings and settings.hud and hudVisible and settings.hudTime and settings.hudTime > 0 then + if os.time() - hudTimestamp >= settings.hudTime then + hideHud() + end end -end) - - + if settings and settings.hud and hudText then + local x, y = hudText:pos() + if type(x) == 'table' then + y = x.y + x = x.x + end + if type(x) == 'number' and type(y) == 'number' then + if x ~= settings.hudX or y ~= settings.hudY then + local now = os.clock() + if now - lastHudSave >= 0.5 then + settings.hudX = x + settings.hudY = y + config.save(settings, 'all') + lastHudSave = now + end + end + end + end +end) defaults = {} defaults.autostopper = true @@ -84,6 +111,12 @@ defaults.effected = 1 defaults.fold = 1 defaults.luckyinfo = true +defaults.hud = false +defaults.hudTime = 5 +defaults.hudX = 900 +defaults.hudY = 300 +defaults.hudDrag = true +defaults.view = 'all' settings = config.load(defaults) windower.register_event('addon command',function (...) @@ -92,6 +125,10 @@ windower.register_event('addon command',function (...) if cmd[1]:lower() == "help" then log('To toggle rolltracker from allowing/stopping rolls type: //rolltracker autostop') log('To toggle rolltracker from showing/hiding Lucky Info type: //rolltracker luckyinfo') + log('To toggle HUD on/off type: //rolltracker hud [on|off|toggle|status]') + log('To set HUD time (seconds) type: //rolltracker hudtime ') + log('To set HUD position type: //rolltracker hudpos ') + log('To view rolls from self/others/all type: //rolltracker view ') elseif cmd[1]:lower() == "autostop" then if settings.autostopper then settings.autostopper = false @@ -108,6 +145,69 @@ windower.register_event('addon command',function (...) settings.luckyinfo = true log('Lucky/Unlucky Info will now be displayed.') end + elseif cmd[1]:lower() == "hud" then + local sub = cmd[2] and cmd[2]:lower() or "toggle" + if sub == "on" then + settings.hud = true + initHud() + applyHudSettings() + log('HUD Enabled.') + elseif sub == "off" then + settings.hud = false + hideHud() + log('HUD Disabled.') + elseif sub == "status" then + log('HUD: ' .. (settings.hud and 'ON' or 'OFF')) + else + settings.hud = not settings.hud + if not settings.hud then + hideHud() + else + initHud() + applyHudSettings() + end + log('HUD: ' .. (settings.hud and 'ON' or 'OFF')) + end + elseif cmd[1]:lower() == "hudtime" then + local t = tonumber(cmd[2]) + if t then + settings.hudTime = t + log('HUD Time: ' .. tostring(settings.hudTime) .. 's') + else + log('Usage: //rolltracker hudtime ') + end + elseif cmd[1]:lower() == "hudpos" then + local x = tonumber(cmd[2]) + local y = tonumber(cmd[3]) + if x and y then + settings.hudX = x + settings.hudY = y + initHud() + applyHudSettings() + log('HUD Position: ' .. tostring(x) .. ', ' .. tostring(y)) + else + log('Usage: //rolltracker hudpos ') + end + elseif cmd[1]:lower() == "hudlock" then + settings.hudDrag = false + applyHudSettings() + log('HUD Drag: OFF') + elseif cmd[1]:lower() == "hudunlock" then + settings.hudDrag = true + initHud() + applyHudSettings() + log('HUD Drag: ON') + elseif cmd[1]:lower() == "view" then + local mode = cmd[2] and cmd[2]:lower() or "" + if mode == "me" or mode == "my" or mode == "mine" then + mode = "self" + end + if mode == "self" or mode == "others" or mode == "all" then + settings.view = mode + log('View Mode: ' .. settings.view) + else + log('Usage: //rolltracker view ') + end end config.save(settings, 'all') end @@ -222,6 +322,14 @@ windower.register_event('action', function(act) local rollID = act.param local rollNum = act.targets[1].actions[1].param + if settings and settings.view and player and player.id then + if settings.view == 'self' and rollActor ~= player.id then + return + elseif settings.view == 'others' and rollActor == player.id then + return + end + end + -- anonymous function that checks if the player.id is in the targets without wrapping it in another layer of for loops. if function(act) @@ -258,8 +366,6 @@ windower.register_event('action', function(act) luckChat = string.char(31,167).." (Unlucky!)" end - - -- HUD details (roll number + Lucky/Unlucky numbers) local lucky_num = rollInfo[rollID][15] local unlucky_num = rollInfo[rollID][16] @@ -277,16 +383,15 @@ windower.register_event('action', function(act) end if rollNum == 12 and #rollMembers > 0 then windower.add_to_chat(1, string.char(31,167)..amountHit..'Bust! '..chat.controls.reset..chars.implies..' '..membersHit..' '..chars.implies..' ('..rollInfo[rollID][rollNum+1]..rollInfo[rollID][14]..')') - rt_show_hud(string.format('%s Roll\nBust!%s', rollInfo[rollID][1], hud_lu)) + showHud(string.format('%s Roll\nBust!%s', rollInfo[rollID][1], hud_lu)) else windower.add_to_chat(1, amountHit..membersHit..chat.controls.reset..' '..chars.implies..' '..rollInfo[rollID][1]..' Roll '..chars['circle' .. rollNum]..luckChat..string.char(31,13)..' (+'..rollBonus..')'..BustRate(rollNum, rollActor)..ReportRollInfo(rollID, rollActor)) - rt_show_hud(string.format('%s Roll %d%s\n+%s%s', rollInfo[rollID][1], rollNum, hud_status, rollBonus, hud_lu)) + showHud(string.format('%s Roll %d%s\n+%s%s', rollInfo[rollID][1], rollNum, hud_status, rollBonus, hud_lu)) end end end end) - function RollEffect(rollid, rollnum) if rollnum == 13 then return @@ -393,7 +498,6 @@ function RollEffect(rollid, rollnum) return rollVal..rollInfo[rollid][14] end - function BustRate(rollNum, rollActor) if rollNum <= 5 or rollNum == 11 or rollActor ~= player.id or settings.bust == 0 then return ''