【发布时间】:2017-06-27 21:01:23
【问题描述】:
如果我想检查一个变量或从我在 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)
在另一个.lua中
local getTable = loadsave.loadTable("table.json", system.DocumentsDirectory)
--here I would like to get the third value from the table and print it
【问题讨论】:
-
getTable.third -
local table()不是有效的 Lua。阅读优秀的书籍Programming in Lua 将有助于回答此类极其基本的问题。第一版免费提供online。