Help with tables and functions

What I want to achieve is a way for a function that is put inside a table to know the table it is in.

Example:

local Table1 = {
 ["Table1a"] = {
  ["Hi"] = 1
  ["Function"] = function()
     print(This tables hi) --I want it to print out 1 since hi in this table = 1
   end
 };
 ["Table2a"] = {
  ["Hi"] = 2
   ["Function"] = function()
     print(This tables hi) --I want it to print out 2 since hi in this table = 2
   end
 };
}

Help would be appreciated!

Nevermind! I found a way to achieve this!

local Table1 = {
	["Table1a"] = {
		["Hi"] = 1,
		["Function"] = function(self)
			print(self["Hi"]) -- prints the value of "Hi" in the current table
		end
	},
	["Table2a"] = {
		["Hi"] = 2,
		["Function"] = function(self)
			print(self["Hi"]) -- prints the value of "Hi" in the current table
		end
	}
}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.