Skip to content

Commit

Permalink
Merge pull request #2090 from xurion/dev
Browse files Browse the repository at this point in the history
Update Mount Roulette to 3.1.0
  • Loading branch information
z16 authored Dec 6, 2021
2 parents 196e629 + bf4ee31 commit ee2b315
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 6 deletions.
83 changes: 78 additions & 5 deletions addons/MountRoulette/MountRoulette.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = S{}
})

math.randomseed(os.time())

Expand All @@ -55,7 +59,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 blacklisted
if not settings.blacklist:contains(mount) then
allowed_mounts_set:add(mount)
end
end
end

Expand All @@ -70,7 +77,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
Expand All @@ -86,4 +95,68 @@ 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 mount in settings.blacklist:it() do
windower.add_to_chat(8, ' ' .. mount)
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 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
settings.blacklist:add(mount)
windower.add_to_chat(8, 'The ' .. mount .. ' mount is now blacklisted')
settings:save()
elseif operation == 'remove' then
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')
settings:save()
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 <mount> - blacklist a mount so it is never randomly selected')
windower.add_to_chat(8, '//mr blacklist remove <mount> - 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)
22 changes: 21 additions & 1 deletion addons/MountRoulette/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <mount>`

Prevents the given mount from being summoned by Mount Roulette.

### Remove a mount from the blacklist

`//mr blacklist remove <mount>`

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.

0 comments on commit ee2b315

Please sign in to comment.