How to print a property of a variable in a table

Well my title is probably wrong but heres an example of what I want to do:

local example\_table = {} local variable variable.text="blah blah blah" example\_table[1]=variable print(example\_table[1].text) --This line^ does not work

How can I print variable.text by printing it through the table?

I know I can just do print(variable.text) but lets say I can’t do this because of “weird” reasons.

thanks a bunch

PS. dont ask what are these “weird” reasons. because rule #1 in fight club is to never talk about fight club.

local myTable={}
local variable=“blabla”
myTable:insert(variable)
print(myTable.variable)

You cant do variable.text=“bla bla” unless the variable is an object. Is that the case here?

My code above assumes your variable is an object

https://roaminggamer.github.io/RGDocs/pages/SSK2/extensions/#table-debug-features

local rec = {} rec.name = "bob" rec.age = 100 rec.inventory = {} rec.inventory[1] = "coin" rec.inventory[2] = "game" -- Dump first level entries in table. table.dump(rec) -- recursively print table table.print\_r(rec)

Thanks for your replies!

Ik I can just probably make that property into a separate object which will save me time in the long run.

But is there no way through corona to print out a property of an object in a table?

@roaminggamer luckily I am using SSK2 so I’ll try that out thanks :slight_smile:

Yes, you’re misunderstanding. ‘variable’ was never a table, therefore variable.text is not a ‘property’ of that table. I’m surprised you didn’t get a runtime error there.

This will work:

[lua]

local variable = {}

variable.text = “blah blah blah”

print (variable.text)

[/lua]

local myTable={}
local variable=“blabla”
myTable:insert(variable)
print(myTable.variable)

You cant do variable.text=“bla bla” unless the variable is an object. Is that the case here?

My code above assumes your variable is an object

https://roaminggamer.github.io/RGDocs/pages/SSK2/extensions/#table-debug-features

local rec = {} rec.name = "bob" rec.age = 100 rec.inventory = {} rec.inventory[1] = "coin" rec.inventory[2] = "game" -- Dump first level entries in table. table.dump(rec) -- recursively print table table.print\_r(rec)

Thanks for your replies!

Ik I can just probably make that property into a separate object which will save me time in the long run.

But is there no way through corona to print out a property of an object in a table?

@roaminggamer luckily I am using SSK2 so I’ll try that out thanks :slight_smile:

Yes, you’re misunderstanding. ‘variable’ was never a table, therefore variable.text is not a ‘property’ of that table. I’m surprised you didn’t get a runtime error there.

This will work:

[lua]

local variable = {}

variable.text = “blah blah blah”

print (variable.text)

[/lua]