-
-
Save Industrial/a41fd78b9d5630d7429fee8411d6007d to your computer and use it in GitHub Desktop.
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
local idTweaks = LibStub('AceAddon-3.0'):GetAddon('idTweaks') | |
local AutomationModule = idTweaks:NewModule('Automation', 'AceConsole-3.0', 'AceEvent-3.0') | |
ChatFrame1:AddMessage('AutomationModule loading..') | |
function AutomationModule:setDefaults() | |
self.defaults = { | |
profile = { | |
sellGreyItems = { | |
enabled = true | |
} | |
} | |
} | |
end | |
function AutomationModule:setDatabase() | |
self.db = idTweaks.db:RegisterNamespace('Automation', self.defaults) | |
end | |
function AutomationModule:setOptions() | |
self.options = { | |
name = 'Automation', | |
handler = self, | |
type = 'group', | |
args = { | |
sellGreyItems = { | |
name = 'Sell grey items', | |
handler = self, | |
type = 'group', | |
args = { | |
mouseWheel = { | |
name = 'Enabled', | |
handler = self, | |
type = 'toggle', | |
get = function() | |
return self.db.profile.sellGreyItems.enabled | |
end, | |
set = function(_, value) | |
self.db.profile.sellGreyItems.enabled = value | |
self.sellGreyItems:checkEnabled() | |
end | |
} | |
} | |
}, | |
} | |
} | |
end | |
function AutomationModule:registerOptions() | |
LibStub('AceConfig-3.0'):RegisterOptionsTable('Automation', self.options) | |
LibStub('AceConfigDialog-3.0'):AddToBlizOptions('Automation', 'Automation', 'idTweaks') | |
end | |
function AutomationModule:OnInitialize() | |
ChatFrame1:AddMessage('AutomationModule:OnInitialize') | |
self:setDefaults() | |
self:setDatabase() | |
self:setOptions() | |
end | |
function AutomationModule:OnEnable() | |
ChatFrame1:AddMessage('AutomationModule:OnEnable') | |
self:registerOptions() | |
self.sellGreyItems:checkEnabled() | |
end | |
function AutomationModule:OnDisable() | |
ChatFrame1:AddMessage('AutomationModule:OnDisable') | |
end | |
AutomationModule.sellGreyItems = {} | |
function AutomationModule.sellGreyItems:MERCHANT_SHOW() | |
ChatFrame1:AddMessage('AutomationModule.sellGreyItems:MERCHANT_SHOW') | |
local link | |
for bag = 0, 4 do | |
for slot = 0, GetContainerNumSlots(bag) do | |
link = GetContainerItemLink(bag, slot) | |
if link and select(3, GetItemInfo(link)) == 0 then | |
ShowMerchantSellCursor(1) | |
UseContainerItem(bag, slot) | |
end | |
end | |
end | |
end | |
function AutomationModule.sellGreyItems:checkEnabled() | |
ChatFrame1:AddMessage('AutomationModule.sellGreyItems.checkEnabled') | |
if AutomationModule.db.profile.sellGreyItems.mouseWheel == true then | |
AutomationModule:RegisterEvent('MERCHANT_SHOW', AutomationModule.sellGreyItems.MERCHANT_SHOW) | |
else | |
AutomationModule:UnregisterEvent('MERCHANT_SHOW') | |
end | |
end | |
idTweaks.Automation = AutomationModule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment