Thread: Table Iteration
View Single Post
03-30-13, 07:44 AM   #3
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
Hey Phanx,

Thanks for the reply.

What I am trying to accomplish is to have two tables of relevant buffs and debuffs, and their respective modification to healing. An example would be:

Lua Code:
  1. -- ["Spell ID"] = percent
  2. local generalHealingIncreases = {
  3.     [47788] = 60,   -- Guardian Spirit
  4.     [55233] = 25    -- Vampiric Blood; needs to be adjusted for glyph.
  5. }

The way healing modifications are handled is multiplicative, from highest to lowest value. What I aim to do is sort the table from highest to lowest by hand, and by having my loop iterate over it in descending order, I can ensure the appropriate buff is calculated first.

That being said, I need to be able to modify the values through a look-up of the keys (to reflect glyphs); and the table would then need to be re-sorted to reflect the new values.

I am not sure that I like the idea of two tables. Is this a situation where metatables would be useful? I was poking around some Lua websites and there was a method utilizing metatables to emulate the next() function, but I wasn't too sure it was what I was looking for.

Thanks for your time and help (as usual ).

Last edited by Clamsoda : 03-30-13 at 09:27 AM.
  Reply With Quote