Thread Tools Display Modes
Prev Previous Post   Next Post Next
11-18-12, 12:42 PM   #1
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
Data structure suggestion

Hi, In my little addons I used a files categories.lua where the users define the custom mounts or pets to be summoned.

The structure is very simple:

Lua Code:
  1. mounts = {
  2.    
  3.    flying = {
  4.         "Draco Del Crepuscolo",
  5.         "Draco Rosso",
  6.         "Fenice Oscura",
  7.         "Proto-Draco Ferroso",
  8.    },
  9.    
  10.    ground = {
  11.         "Fiera della Luna Rapida",
  12.         "Fiera della Nebbia Rapida",
  13.         "Fiera della Notte Striata",
  14.  
  15.      },
  16.    
  17. [etc etc ...]
  18.  
  19. }

Now I'd like to try to move and replicate this data structure into the addons to use the WTF store method. But what I think was easy is not so easy.

Let's suppose I wanna add a mount in a category not yet defined with the syntax:

/mrc add new_category Swift Moonsaber

The parsing should be ok and suppose I have:

Lua Code:
  1. mounts = {}
  2. category="new_category"
  3. mount="Swift Moonsaber"

I thought that it could be simple as push a new entry in this way:

Lua Code:
  1. mounts[category][mount]=true

but here lua complain something about attempt to index field '?' (a nil value).

I try also with table.insert without any fortune.

I don't think things change so much removing one level ( categories[mount]=true ) being this to be pushed inside the mounts{} to be saved later.

Thanks in advance for your patience.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Data structure suggestion


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off