View Single Post
10-17-14, 10:50 PM   #1
Blooblahguy
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 18
Issues with table indices

As the title suggest, having issues with some tables/indices that i'm using in an addon i'm working on and I'm absolutely stumped.

I'll try my best to explain it before linking my code. But basically I have a table format of table_name[itemID][raidIndex] = stored_frame. Looping through the table using table.foreach returns this structure, however accessing the table using the above string returns a nil index error. Here's my code to hopefully provide some clarity.

I set my table here for each entry
Code:
table.insert(entry_frames, itemID, {[raidIndex] = entryframe})
Now later I'm trying to fetch that entryframe on it and run code on it.

Code:
table.foreach(entry_frames, function(a, b)
	print("a: "..a) -- returns the itemID
	-- b returns the table below
	table.foreach(b, function(raidIndex, bb)
		print("aa: "..aa) - -returns the raid index
		--print("bb: "..bb) returns nil
	end)
end)

print(entry_frames[itemID][raidIndex]) -- throws fatal index ? error
Now what I want to do it both remove this frame/indices from the table and then run a function on the frame to return it to my frame cache

Code:
table.remove(entry_frames, itemID[raidIndex])
destroy_frame(_G["vote_entry:"..itemID..":"..raidIndex])
Of course these both fail as is. Any insights?
  Reply With Quote