Originally Posted by myrroddin
Right now you are (re)defining the variables on every loop, creating unnecessary garbage collection and a great deal of inefficiency.
Lua Code:
local AllianceMammoth, HordeMammoth, GrandExpedYak = 61425, 61447, 122708 for i = 1, numMounts do if creatureSpellID == AllianceMammoth or creatureSpellID == HordeMammoth or creatureSpellID == GrandExpedYak then tinsert(mounts.vendor, {i, creatureID, creatureName, creatureSpellID, icon, issummoned, mountType}) end end
|
Only the first line in the code you quoted creates variables that could be defined at the file level. The other 3 lines must be done
inside the loop over all of the player's mounts, as all the variables it references do not exist outside the loop.
However, redefining 3 number values whenever COMPANION_UPDATE fires is hardly "a great deal of inefficiency", especially for the purposes of a beginner still trying to figure out the basic logic.