-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mountmuzzle] support custom BGM per mount
- Loading branch information
Showing
2 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,20 +29,22 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
_addon.name = 'Mount Muzzle' | ||
_addon.description = 'Change or remove the default mount music.' | ||
_addon.author = 'Sjshovan (Apogee) [email protected]' | ||
_addon.version = '0.9.5' | ||
_addon.version = '0.9.6' | ||
_addon.commands = {'mountmuzzle', 'muzzle', 'mm'} | ||
|
||
local _logger = require('logger') | ||
local _config = require('config') | ||
local _packets = require('packets') | ||
local _resources = require('resources') | ||
|
||
require('constants') | ||
require('helpers') | ||
|
||
local needs_inject = false | ||
|
||
local defaults = { | ||
muzzle = muzzles.silent.name | ||
muzzle = muzzles.silent.name, | ||
custom = {} | ||
} | ||
|
||
local settings = _config.load(defaults) | ||
|
@@ -70,6 +72,7 @@ local help = { | |
buildHelpTypeEntry(muzzles.mount.name:ucfirst(), muzzles.mount.description), | ||
buildHelpTypeEntry(muzzles.chocobo.name:ucfirst(), muzzles.chocobo.description), | ||
buildHelpTypeEntry(muzzles.zone.name:ucfirst(), muzzles.zone.description), | ||
buildHelpTypeEntry(muzzles.custom.name:ucfirst(), muzzles.custom.description), | ||
buildHelpSeperator('=', 23), | ||
}, | ||
about = { | ||
|
@@ -87,11 +90,17 @@ local help = { | |
s = muzzles.silent.name, | ||
m = muzzles.mount.name, | ||
c = muzzles.chocobo.name, | ||
z = muzzles.zone.name | ||
z = muzzles.zone.name, | ||
u = muzzles.custom.name | ||
} | ||
} | ||
} | ||
|
||
local possible_mounts = L{} | ||
for _, mount in pairs(_resources.mounts) do | ||
possible_mounts:append(mount.name:lower()) | ||
end | ||
|
||
function display_help(table_help) | ||
for index, command in pairs(table_help) do | ||
displayResponse(command) | ||
|
@@ -126,6 +135,11 @@ function setMuzzle(muzzle) | |
settings:save() | ||
end | ||
|
||
function setCustom(mount, song) | ||
settings.custom[mount] = song | ||
settings:save() | ||
end | ||
|
||
function playerInReive() | ||
return getPlayerBuffs():contains(player.buffs.reiveMark) | ||
end | ||
|
@@ -209,6 +223,19 @@ windower.register_event('addon command', function(command, ...) | |
response_message = 'Updated current muzzle to %s.':format(muzzle:ucfirst():color(colors.secondary)) | ||
end | ||
|
||
elseif command == 'customize' or command == 'c' then | ||
respond = true | ||
|
||
local mount = command_args[1]:lower() | ||
local song = tonumber(command_args[2]) | ||
if not possible_mounts:contains(mount) then | ||
success = false | ||
response_message = 'Unknown mount %s.':format(mount:color(colors.secondary)) | ||
else | ||
setCustom(mount, song) | ||
response_message = 'Set music for %s to track %s, %s.':format(mount:color(colors.secondary), tostring(song), songs[song]:color(colors.secondary)) | ||
end | ||
|
||
elseif command == 'get' or command == 'g' then | ||
respond = true | ||
response_message = 'Current muzzle is %s.':format(getMuzzle():ucfirst():color(colors.secondary)) | ||
|
@@ -258,4 +285,14 @@ windower.register_event('incoming chunk', function(id, data) | |
|
||
tryInject() | ||
end | ||
end) | ||
|
||
windower.register_event('outgoing chunk',function(id, data) | ||
if id == packets.outbound.action.categories.mount then | ||
if getMuzzle() == 'custom' then | ||
local packet = _packets.parse('outgoing', data) | ||
local mount = packet['Param'] | ||
muzzles.custom.song = settings.custom[possible_mounts[mount]] | ||
end | ||
end | ||
end) |