如何从 Corona SDK 中的 table 获取 value/variable?

How to get a value/variable from a table in corona SDK?

如果我想检查一个变量或从我在 Corona SDK 中创建的 table 中获取一个值怎么办?我知道你在 C++ 中使用索引号,但是当我尝试它时它不起作用。

在main.lua中:

local table = {}
table.first = "string"
table.second = 25
table.third = "I want to get this one"

loadsave.saveTable(table,"table.json", system.DocumentsDirectory)

在another.lua

local getTable = loadsave.loadTable("table.json", system.DocumentsDirectory)
--here I would like to get the third value from the table and print it

试试这个:

local table = {}
table.third = "I want to get this one"

print( table.third )
===============================
output: "I want to get this one"

Also check this link for more about tables in lua