Mercurial > wow > cyborg-mmo7
changeset 68:840c9f09a707 v6.0.3-1
Removed the old companion code, and convert saved ones (which should already be mounts, not critters) to the 'mount' type.
author | Jerome Vuarand <jerome.vuarand@gmail.com> |
---|---|
date | Thu, 23 Oct 2014 17:11:47 +0100 |
parents | 2d6684c270b9 |
children | 5165c2d211dd |
files | RatPageController.lua WowObjects.lua |
diffstat | 2 files changed, 30 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/RatPageController.lua Thu Oct 23 15:51:26 2014 +0100 +++ b/RatPageController.lua Thu Oct 23 17:11:47 2014 +0100 @@ -88,10 +88,6 @@ local index = a local name = GetMacroInfo(index) return CyborgMMO_CreateWowObject('macro', name) - elseif type=='companion' then - local index,subtype = a,b - local spellID = select(3, GetCompanionInfo(subtype, index)) - return CyborgMMO_CreateWowObject('companion', spellID) elseif type=='battlepet' then local petID = a return CyborgMMO_CreateWowObject('battlepet', petID)
--- a/WowObjects.lua Thu Oct 23 15:51:26 2014 +0100 +++ b/WowObjects.lua Thu Oct 23 17:11:47 2014 +0100 @@ -215,62 +215,6 @@ ------------------------------------------------------------------------------ -local WowCompanion_methods = setmetatable({}, {__index=WowObject_methods}) -local WowCompanion_mt = {__index=WowCompanion_methods} - -local function WowCompanion(spellID) - local texture = select(3, GetSpellInfo(spellID)) - if not texture then - return nil - end - - local self = WowObject("companion", spellID) - CyborgMMO_DPrint("creating companion binding:", type, spellID) - - self.spellID = spellID - self.texture = texture - - setmetatable(self, WowCompanion_mt) - - return self -end - -local function IdentifyCompanion(spellID) - for _,subtype in ipairs{'MOUNT', 'CRITTER'} do - for index=1,GetNumCompanions(subtype) do - local spellID2,_,active = select(3, GetCompanionInfo(subtype, index)) - if spellID2 == spellID then - return subtype,index,active - end - end - end -end - -function WowCompanion_methods:DoAction() - local subtype,index,active = IdentifyCompanion(self.spellID) --- if subtype == "MOUNT" and IsMounted() then - if subtype == "MOUNT" and active then - Dismount() - elseif subtype and index then - CallCompanion(subtype, index) - end -end - -function WowCompanion_methods:Pickup() --- PlaySound("igAbilityIconDrop") - local subtype,index = IdentifyCompanion(self.spellID) - if subtype and index then - return PickupCompanion(subtype, index) - end -end - -function WowCompanion_methods:SetBinding(key) - local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory:AddCallback(function() self:DoAction() end) - SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton") -end - ------------------------------------------------------------------------------- - local WowEquipmentSet_methods = setmetatable({}, {__index=WowObject_methods}) local WowEquipmentSet_mt = {__index=WowEquipmentSet_methods} @@ -377,6 +321,30 @@ return nil,"not in journal" end +local function FindMountFromSpellID(spellID) + for mount,spell in pairs(CyborgMMO_MountMap) do + if spell==spellID then + return mount + end + end + for mount,spell in pairs(CyborgMMO_MountMap) do + if spell==spellID then + return mount + end + end + for i=1,C_MountJournal.GetNumMounts() do + local _,spell = C_MountJournal.GetMountInfo(i) + if spell==spellID then + local cursor = pack(GetCursorInfo()) + C_MountJournal.Pickup(i) + local _,mountID = GetCursorInfo() + ClearCursor() + return mountID + end + end + return nil +end + local WowMount_methods = setmetatable({}, {__index=WowObject_methods}) local WowMount_mt = {__index=WowMount_methods} @@ -473,7 +441,12 @@ elseif type == "spell" then object = WowSpell(...) elseif type == "companion" then - object = WowCompanion(...) + -- most likely a legacy mount in an old SavedVariables + local spellID = ... + local mountID = FindMountFromSpellID(spellID) + if mountID then + object = WowMount(mountID) + end elseif type == "equipmentset" then object = WowEquipmentSet(...) elseif type == "battlepet" then