Lua tables can be used as both indexed and associative arrays
(if that's what you mean with dictionaries)
https://www.lua.org/pil/2.5.html -- Tables
http://www.lua.org/pil/11.2.html -- Matrices and Multi-Dimensional Arrays
Here are 2 examples of associative tables
Lua Code:
local myTable = {
India = "juliet",
alpha = "bravo",
echo = "foxtrot",
Charlie = "delta",
golf = "hotel",
}
local someTable = {}
someTable.foo = "hello"
someTable["bar"] = 123
someTable[7] = "world"
Another 2 examples of a multidimensional array/table
Lua Code:
-- sequential/index keys can be ommitted in this case but just an example
local myTable = {
[1] = {1, 2, 3},
[2] = {1, 2, 3},
[3] = {1, 2, 3},
[4] = {1, 2, 3},
}
local someTable = {}
for i = 1, 4 do
someTable[i] = {}
for j = 1, 3 do
someTable[i][j] = j
end
end
Originally Posted by Twitchy250
The way I am trying to lay out the dictionary is UrchinDictionary as the primary dictionary table with the key [1] holding a setting determining the number of snapshots of the AH to hold and [2]-[3]-[4] ect holding each snapshot.
Because each snapshot can contain a lot of info on a single item due to multiple listings, it makes it a little more complicated. (reading the dictionary to me is the easy part)
|
Looking at your code I would rewrite it like this (untested),
but I honestly... can't understand what you're trying to do so there's probably a better way to do this :S
Lua Code:
local dictionaryFix = {}
local function ReadAH()
local _, totalAuctions = GetNumAuctionItems("list")
for i = 1, totalAuctions do -- sorry for wasting tables
dictionaryFix[i] = {GetAuctionItemInfo("list", i)}
end
end
(edit) wait, why couldn't you just continue in your previous thread? :x
http://www.wowinterface.com/forums/s...ad.php?t=54731