Quantcast
Channel: How to reference lua table member from table member? - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by furq for How to reference lua table member from table member?

$
0
0

There's no way of doing this inside the constructor itself, but you can do it after creating the table like so:

enUS = {   LOCALE_STHOUSANDS = ","}enUS.patNumber = "%d+["..enUS.LOCALE_STHOUSANDS.."%d]*"enUS.PreScanPatterns = {  ["^("..enUS.patNumber..") Armor$"] = "ARMOR",}

If you specifically need to refer to the current table, Lua provides a "self" parameter, but it's only accessible in functions.

local t = {  x = 1,  y = function(self) return self.x end} -- this is functionally identical to t.yfunction t:z() return self.x end-- these are identical and interchangeableprint(t:y(), t.z(t))-- 1, 1

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles



Latest Images