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

How to reference lua table member from table member?

$
0
0

i have a table in lua:

enUS = {   LOCALE_STHOUSANDS = ",",  --Thousands separator e.g. comma   patNumber = "%d+["..LOCALE_STHOUSANDS.."%d]*", --regex to find a number   ["PreScanPatterns"] = {      ["^("..patNumber..") Armor$"] = "ARMOR",   }}

So you see there is a whole chain of self-references in this table:

  • LOCAL_STHOUSANDS
    • patNumber
      • ["^("..patNumber..") Armor$"]

How can i perform self-referencing in an lua table?


What i don't want to do is have to hard-replace the values; there are hundreds of references:

enUS = {   LOCALE_STHOUSANDS = ",",  --Thousands separator e.g. comma   patNumber = "%d+[,%d]*", --regex to find a number   ["PreScanPatterns"] = {      ["^(%d+[,%d]*) Armor$"] = "ARMOR",   }}

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>