From b09d2e31e05023d0aff6c5fa08477769e1c772f9 Mon Sep 17 00:00:00 2001 From: Dean James Date: Sat, 6 Nov 2021 23:26:53 +0000 Subject: [PATCH 1/3] Update Mount Roulette to 3.1.0. Add blacklist function. --- addons/MountRoulette/MountRoulette.lua | 95 ++++++++++++++++++++++++-- addons/MountRoulette/README.md | 22 +++++- 2 files changed, 111 insertions(+), 6 deletions(-) diff --git a/addons/MountRoulette/MountRoulette.lua b/addons/MountRoulette/MountRoulette.lua index 0b272b70e3..3dfab1232e 100644 --- a/addons/MountRoulette/MountRoulette.lua +++ b/addons/MountRoulette/MountRoulette.lua @@ -26,14 +26,18 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ]] -_addon.name = 'Mount Roulette' -_addon.author = 'Dean James (Xurion of Bismarck)' -_addon.version = '3.0.1' +_addon.name = 'Mount Roulette' +_addon.author = 'Dean James (Xurion of Bismarck)' +_addon.version = '3.1.0' _addon.commands = {'mountroulette', 'mr'} require('lists') require('sets') resources = require('resources') +config = require('config') +settings = config.load({ + blacklist = '' +}) math.randomseed(os.time()) @@ -43,6 +47,13 @@ for _, mount in pairs(resources.mounts) do possible_mounts:append(mount.name:lower()) end +blacklist = {} +if string.len(settings.blacklist) > 0 then + for mount in settings.blacklist:gmatch("([^,]+)") do + table.insert(blacklist, mount) + end +end + function update_allowed_mounts() local allowed_mounts_set = S{} local kis = windower.ffxi.get_key_items() @@ -55,7 +66,10 @@ function update_allowed_mounts() end) local mount = possible_mounts[mount_index] - allowed_mounts_set:add(mount) + -- Add this to allowed mounts if it is not already there and it is not blacklisted + if not allowed_mounts:contains(mount) and not S(blacklist):contains(mount) then + allowed_mounts_set:add(mount) + end end end @@ -70,7 +84,9 @@ windower.register_event('incoming chunk', function(id) end end) -windower.register_event('addon command', function() +commands = {} + +commands.mount = function() local player = windower.ffxi.get_player() -- If the player is mounted, dismount now @@ -86,4 +102,73 @@ windower.register_event('addon command', function() -- Generate random number and use it to choose a mount local mount_index = math.ceil(math.random() * #allowed_mounts) windower.send_command('input /mount "' .. allowed_mounts[mount_index] .. '"') +end + +commands.blacklist = function(args) + local operation = args:remove(1) + + if not operation then + windower.add_to_chat(8, 'Blacklisted mounts:') + for k, v in ipairs(blacklist) do + windower.add_to_chat(8, ' ' .. v) + end + return + end + + local mount = args:concat(' '):lower() + + if not operation or not mount then + commands.help() + return + end + + if not possible_mounts:contains(mount) then + windower.add_to_chat(8, 'Unknown mount ' .. mount) + return + end + + if operation == 'add' and not S(blacklist):contains(mount) then + for k, v in ipairs(T(allowed_mounts)) do + if v == mount then + allowed_mounts:remove(k) + end + end + table.insert(blacklist, mount) + windower.add_to_chat(8, 'The ' .. mount .. ' mount is now blacklisted') + save_settings() + elseif operation == 'remove' then + for k, v in ipairs(blacklist) do + if v == mount then + table.remove(blacklist, k) + end + end + allowed_mounts:append(mount) + windower.add_to_chat(8, 'The ' .. mount .. ' mount is no longer blacklisted') + save_settings() + end +end + +commands.help = function() + windower.add_to_chat(8, '---Mount Roulette---') + windower.add_to_chat(8, 'Available commands:') + windower.add_to_chat(8, '//mr mount (or just //mr) - Selects a mount at random, or dismounts if mounted') + windower.add_to_chat(8, '//mr blacklist - show blacklisted mounts') + windower.add_to_chat(8, '//mr blacklist add - blacklist a mount so it is never randomly selected') + windower.add_to_chat(8, '//mr blacklist remove - remove a mount from the blacklist') + windower.add_to_chat(8, '//mr help - displays this help') +end + +windower.register_event('addon command', function(command, ...) + command = command and command:lower() or 'mount' + + if commands[command] then + commands[command](L{...}) + else + commands.help() + end end) + +function save_settings() + settings.blacklist = table.concat(blacklist, ",") + settings:save() +end diff --git a/addons/MountRoulette/README.md b/addons/MountRoulette/README.md index 5072d4ae26..c0f8620138 100644 --- a/addons/MountRoulette/README.md +++ b/addons/MountRoulette/README.md @@ -8,10 +8,30 @@ Get the addon from the addon section of the Windower launcher. ### Summon a mount -`//mr` +`//mr` (or `//mr mount`) This will also dismount you if you're currently mounted. +### Add a mount to the blacklist + +`//mr blacklist add ` + +Prevents the given mount from being summoned by Mount Roulette. + +### Remove a mount from the blacklist + +`//mr blacklist remove ` + +Allows the given mount to be summoned by Mount Roulette. + +### List blacklisted mounts + +`//mr blacklist` + +### Show help and commands + +`//mr help` + ## Mount music In an earlier version, this addon disabled mount music. This is now removed in favour of the MountMuzzle addon. From bf4ee315782e3a6090992e2f3f81cd250c751c7d Mon Sep 17 00:00:00 2001 From: Dean James Date: Sun, 14 Nov 2021 01:33:52 +0000 Subject: [PATCH 2/3] Use set directly in settings table. Use convenient iterator methods. PR feedback. --- addons/MountRoulette/MountRoulette.lua | 42 +++++++++----------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/addons/MountRoulette/MountRoulette.lua b/addons/MountRoulette/MountRoulette.lua index 3dfab1232e..220cae44ec 100644 --- a/addons/MountRoulette/MountRoulette.lua +++ b/addons/MountRoulette/MountRoulette.lua @@ -36,7 +36,7 @@ require('sets') resources = require('resources') config = require('config') settings = config.load({ - blacklist = '' + blacklist = S{} }) math.randomseed(os.time()) @@ -47,13 +47,6 @@ for _, mount in pairs(resources.mounts) do possible_mounts:append(mount.name:lower()) end -blacklist = {} -if string.len(settings.blacklist) > 0 then - for mount in settings.blacklist:gmatch("([^,]+)") do - table.insert(blacklist, mount) - end -end - function update_allowed_mounts() local allowed_mounts_set = S{} local kis = windower.ffxi.get_key_items() @@ -66,8 +59,8 @@ function update_allowed_mounts() end) local mount = possible_mounts[mount_index] - -- Add this to allowed mounts if it is not already there and it is not blacklisted - if not allowed_mounts:contains(mount) and not S(blacklist):contains(mount) then + -- Add this to allowed mounts if it is not blacklisted + if not settings.blacklist:contains(mount) then allowed_mounts_set:add(mount) end end @@ -109,8 +102,8 @@ commands.blacklist = function(args) if not operation then windower.add_to_chat(8, 'Blacklisted mounts:') - for k, v in ipairs(blacklist) do - windower.add_to_chat(8, ' ' .. v) + for mount in settings.blacklist:it() do + windower.add_to_chat(8, ' ' .. mount) end return end @@ -127,24 +120,24 @@ commands.blacklist = function(args) return end - if operation == 'add' and not S(blacklist):contains(mount) then - for k, v in ipairs(T(allowed_mounts)) do - if v == mount then - allowed_mounts:remove(k) + if operation == 'add' and not settings.blacklist:contains(mount) then + for allowed_mount, index in allowed_mounts:it() do + if allowed_mount == mount then + allowed_mounts:remove(index) end end - table.insert(blacklist, mount) + settings.blacklist:add(mount) windower.add_to_chat(8, 'The ' .. mount .. ' mount is now blacklisted') - save_settings() + settings:save() elseif operation == 'remove' then - for k, v in ipairs(blacklist) do - if v == mount then - table.remove(blacklist, k) + for blacklisted_mount in settings.blacklist:it() do + if blacklisted_mount == mount then + settings.blacklist:remove(mount) end end allowed_mounts:append(mount) windower.add_to_chat(8, 'The ' .. mount .. ' mount is no longer blacklisted') - save_settings() + settings:save() end end @@ -167,8 +160,3 @@ windower.register_event('addon command', function(command, ...) commands.help() end end) - -function save_settings() - settings.blacklist = table.concat(blacklist, ",") - settings:save() -end From cc0fd2eec1e046f60f887d8ce8cffa685b12b851 Mon Sep 17 00:00:00 2001 From: KenshiDRK Date: Wed, 8 Dec 2021 14:52:40 +0100 Subject: [PATCH 3/3] [fields.lua] Fix for Accolades Fix for Accolades (Unity points) --- addons/libs/packets/fields.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/libs/packets/fields.lua b/addons/libs/packets/fields.lua index 7f13dc333c..be0a844d54 100644 --- a/addons/libs/packets/fields.lua +++ b/addons/libs/packets/fields.lua @@ -2999,8 +2999,8 @@ fields.incoming[0x061] = L{ {ctype='unsigned char', label='_unknown5'}, -- 57 Always 00 for me {ctype='bit[5]', label='Unity ID'}, -- 58 0=None, 1=Pieuje, 2=Ayame, 3=Invincible Shield, 4=Apururu, 5=Maat, 6=Aldo, 7=Jakoh Wahcondalo, 8=Naja Salaheem, 9=Flavira {ctype='bit[5]', label='Unity Rank'}, -- 58 Danger, 00ing caused my client to crash - {ctype='bit[16]', label='Unity Points'}, -- 59 - {ctype='bit[6]', label='_unknown6'}, -- 5A No obvious function + {ctype='bit[17]', label='Unity Points'}, -- 59 + {ctype='bit[5]', label='_unknown6'}, -- 5A No obvious function {ctype='unsigned int', label='_junk1'}, -- 5C {ctype='unsigned int', label='_junk2'}, -- 60 {ctype='unsigned char', label='_unknown7'}, -- 64