Mercurial > wow > mylilpony
comparison libMyLilPony/libMyLilPony_mountFunctions.lua @ 52:64e8f8e5fa41
Simplified some functions since mount type is can be determined from slot ID
| author | syzler |
|---|---|
| date | Sat, 07 Mar 2015 14:15:17 -0500 |
| parents | 22011265a16f |
| children | d3d070ea6341 |
comparison
equal
deleted
inserted
replaced
| 51:9d3c8c1e84f3 | 52:64e8f8e5fa41 |
|---|---|
| 1 -- Copyright (c) 2011, Syzler | 1 -- Copyright (c) 2015, Syzler |
| 2 -- All rights reserved. | 2 -- All rights reserved. |
| 3 -- | 3 -- |
| 4 -- Redistribution and use in source and binary forms, with or without | 4 -- Redistribution and use in source and binary forms, with or without |
| 5 -- modification, are permitted provided that the following conditions | 5 -- modification, are permitted provided that the following conditions |
| 6 -- are met: | 6 -- are met: |
| 52 -- Does nothing if the only available mount is already summoned. | 52 -- Does nothing if the only available mount is already summoned. |
| 53 -- @return A Boolean value indicating whether or not a mount was successfully summoned. | 53 -- @return A Boolean value indicating whether or not a mount was successfully summoned. |
| 54 function MyLilPony.CallFlyingMount() | 54 function MyLilPony.CallFlyingMount() |
| 55 local filter = function (i) | 55 local filter = function (i) |
| 56 local _, id, _, summoned = C_MountJournal.GetMountInfo(i); | 56 local _, id, _, summoned = C_MountJournal.GetMountInfo(i); |
| 57 return not summoned and MyLilPony.IsFlyingMount(id); | 57 return not summoned and MyLilPony.IsFlyingMountSlot(i); |
| 58 end | 58 end |
| 59 return MyLilPony.CallMountByFilter(filter); | 59 return MyLilPony.CallMountByFilter(filter); |
| 60 end | 60 end |
| 61 | 61 |
| 62 --- Summons a random ground mount. | 62 --- Summons a random ground mount. |
| 63 -- Does nothing if the only available mount is already summoned. | 63 -- Does nothing if the only available mount is already summoned. |
| 64 -- @return A Boolean value indicating whether or not a mount was successfully summoned. | 64 -- @return A Boolean value indicating whether or not a mount was successfully summoned. |
| 65 function MyLilPony.CallGroundMount() | 65 function MyLilPony.CallGroundMount() |
| 66 local filter = function (i) | 66 local filter = function (i) |
| 67 local _, id, _, summoned = C_MountJournal.GetMountInfo(i); | 67 local _, id, _, summoned = C_MountJournal.GetMountInfo(i); |
| 68 return not summoned and MyLilPony.IsGroundMount(id); | 68 return not summoned and MyLilPony.IsGroundMountSlot(i); |
| 69 end | 69 end |
| 70 return MyLilPony.CallMountByFilter(filter); | 70 return MyLilPony.CallMountByFilter(filter); |
| 71 end | 71 end |
| 72 | 72 |
| 73 --- Summons a random aquatic mount. | 73 --- Summons a random aquatic mount. |
| 74 -- Does nothing if the only available mount is already summoned. | 74 -- Does nothing if the only available mount is already summoned. |
| 75 -- @return A Boolean value indicating whether or not a mount was successfully summoned. | 75 -- @return A Boolean value indicating whether or not a mount was successfully summoned. |
| 76 function MyLilPony.CallAquaticMount() | 76 function MyLilPony.CallAquaticMount() |
| 77 local filter = function (i) | 77 local filter = function (i) |
| 78 local _, id, _, summoned = C_MountJournal.GetMountInfo(i); | 78 local _, id, _, summoned = C_MountJournal.GetMountInfo(i); |
| 79 return not summoned and MyLilPony.IsAquaticMount(id); | 79 return not summoned and MyLilPony.IsAquaticMountSlot(i); |
| 80 end | 80 end |
| 81 return MyLilPony.CallMountByFilter(filter); | 81 return MyLilPony.CallMountByFilter(filter); |
| 82 end | 82 end |
| 83 | 83 |
| 84 --- Summons a mount by slot number in mount spellbook. | 84 --- Summons a mount by slot number in mount spellbook. |
| 87 -- @return A Boolean value indicating whether or not a mount was successfully summoned. | 87 -- @return A Boolean value indicating whether or not a mount was successfully summoned. |
| 88 function MyLilPony.CallMountBySlot(slotNumber) | 88 function MyLilPony.CallMountBySlot(slotNumber) |
| 89 local countMounts = C_MountJournal.GetNumMounts(); | 89 local countMounts = C_MountJournal.GetNumMounts(); |
| 90 if slotNumber > 0 and slotNumber < countMounts+1 then | 90 if slotNumber > 0 and slotNumber < countMounts+1 then |
| 91 local _, _, _, summoned = C_MountJournal.GetMountInfo(i); | 91 local _, _, _, summoned = C_MountJournal.GetMountInfo(i); |
| 92 MyLilPony.CallCompanion("MOUNT", slotNumber, not summoned); | 92 MyLilPony.CallMount(slotNumber, not summoned); |
| 93 return true; | 93 return true; |
| 94 end | 94 end |
| 95 return false; | 95 return false; |
| 96 end | 96 end |
| 97 | 97 |
| 102 function MyLilPony.CallMountByName(mountName) | 102 function MyLilPony.CallMountByName(mountName) |
| 103 local result = false; | 103 local result = false; |
| 104 for i in MyLilPony.EnumerateKnownMountSlotIDs() do | 104 for i in MyLilPony.EnumerateKnownMountSlotIDs() do |
| 105 local name, _, _, summoned = C_MountJournal.GetMountInfo(i); | 105 local name, _, _, summoned = C_MountJournal.GetMountInfo(i); |
| 106 if name == mountName then | 106 if name == mountName then |
| 107 MyLilPony.CallCompanion("MOUNT", i, not summoned); | 107 MyLilPony.CallMount(i, not summoned); |
| 108 result = true; | 108 result = true; |
| 109 do break end | 109 do break end |
| 110 end | 110 end |
| 111 end | 111 end |
| 112 return result; | 112 return result; |
| 133 local result = false; | 133 local result = false; |
| 134 for i in MyLilPony.EnumerateKnownMountSlotIDs() do | 134 for i in MyLilPony.EnumerateKnownMountSlotIDs() do |
| 135 local _, spellId, _, summoned = C_MountJournal.GetMountInfo(i); | 135 local _, spellId, _, summoned = C_MountJournal.GetMountInfo(i); |
| 136 local creatureId = C_MountJournal.GetMountInfoExtra(i); | 136 local creatureId = C_MountJournal.GetMountInfoExtra(i); |
| 137 if id == creatureId or id == spellId then | 137 if id == creatureId or id == spellId then |
| 138 MyLilPony.CallCompanion("MOUNT", i, not summoned); | 138 MyLilPony.CallMount(i, not summoned); |
| 139 result = true; | 139 result = true; |
| 140 do break end | 140 do break end |
| 141 end | 141 end |
| 142 end | 142 end |
| 143 return result; | 143 return result; |
| 150 function MyLilPony.CallMountBySpell(spellId) | 150 function MyLilPony.CallMountBySpell(spellId) |
| 151 local result = false; | 151 local result = false; |
| 152 for i in MyLilPony.EnumerateKnownMountSlotIDs() do | 152 for i in MyLilPony.EnumerateKnownMountSlotIDs() do |
| 153 local _, id, _, summoned = C_MountJournal.GetMountInfo(i); | 153 local _, id, _, summoned = C_MountJournal.GetMountInfo(i); |
| 154 if id == spellId then | 154 if id == spellId then |
| 155 MyLilPony.CallCompanion("MOUNT", i, not summoned); | 155 MyLilPony.CallMount(i, not summoned); |
| 156 result = true; | 156 result = true; |
| 157 do break end | 157 do break end |
| 158 end | 158 end |
| 159 end | 159 end |
| 160 return result; | 160 return result; |
| 168 local result = false; | 168 local result = false; |
| 169 for i in MyLilPony.EnumerateKnownMountSlotIDs() do | 169 for i in MyLilPony.EnumerateKnownMountSlotIDs() do |
| 170 local _, _, _, summoned = C_MountJournal.GetMountInfo(i); | 170 local _, _, _, summoned = C_MountJournal.GetMountInfo(i); |
| 171 local id = C_MountJournal.GetMountInfoExtra(i); | 171 local id = C_MountJournal.GetMountInfoExtra(i); |
| 172 if id == creatureId then | 172 if id == creatureId then |
| 173 MyLilPony.CallCompanion("MOUNT", i, not summoned); | 173 MyLilPony.CallMount(i, not summoned); |
| 174 result = true; | 174 result = true; |
| 175 do break end | 175 do break end |
| 176 end | 176 end |
| 177 end | 177 end |
| 178 return result; | 178 return result; |
| 189 local result = false; | 189 local result = false; |
| 190 local unitBuffs = MyLilPony.GetUnitBuffs(unit); | 190 local unitBuffs = MyLilPony.GetUnitBuffs(unit); |
| 191 for i in MyLilPony.EnumerateKnownMountSlotIDs() do | 191 for i in MyLilPony.EnumerateKnownMountSlotIDs() do |
| 192 local _, id, _, summoned = C_MountJournal.GetMountInfo(i); | 192 local _, id, _, summoned = C_MountJournal.GetMountInfo(i); |
| 193 if unitBuffs[id] ~= nil then | 193 if unitBuffs[id] ~= nil then |
| 194 MyLilPony.CallCompanion("MOUNT", i, not summoned); | 194 MyLilPony.CallMount(i, not summoned); |
| 195 result = true; | 195 result = true; |
| 196 do break end | 196 do break end |
| 197 end | 197 end |
| 198 end | 198 end |
| 199 return result; | 199 return result; |
| 219 end | 219 end |
| 220 | 220 |
| 221 if x > 0 then | 221 if x > 0 then |
| 222 local i = mounts[random(1, x)]; | 222 local i = mounts[random(1, x)]; |
| 223 local _, _, _, summoned = C_MountJournal.GetMountInfo(i); | 223 local _, _, _, summoned = C_MountJournal.GetMountInfo(i); |
| 224 MyLilPony.CallCompanion("MOUNT", i, not summoned); | 224 MyLilPony.CallMount(i, not summoned); |
| 225 return true; | 225 return true; |
| 226 end | 226 end |
| 227 return false; | 227 return false; |
| 228 end | 228 end |
| 229 | 229 |
