如何从corona SDK中的表中获取值/变量?

时间:2017-06-23 12:36:21

标签: lua corona

如果我想检查一个变量或从我在corona SDK中创建的表中获取一个值,该怎么办?我知道你在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)

in 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

1 个答案:

答案 0 :(得分:1)

试试这个:

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