如何在 Corona SDK 的加载保存 table 中更新一个变量
How do you update one variable in a load-save table in corona SDK
是否可以使用 load/save json 保存方法更新 table 的一个变量?我想在另一个中更改一个 value/variable .lua 文件。我该如何做到这一点?
我的main.lua:
local table = {}
table.one = "no"
table.two = "no"
table.three = "no"
loadsave.saveTabe(table, "trying.json", system.DocumentsDirectory)
在check.lua中:
local value = loadsave.loadTable("trying.json, system.DocumentsDirectory)
if( 5+5 == 10)then
value.one = "yes"
--HERE I WANT TO SAVE THE VALUE TO THE SAME JSON FILE WITHOUT CHANGING THE OTHER VALUES/VARIABLES ETC.
end
试试这个:
local value = loadsave.loadTable("trying.json", system.DocumentsDirectory)
if( 5+5 == 10) then
value.one = "yes"
loadsave.saveTable(value, "trying.json", system.DocumentsDirectory)
end
是否可以使用 load/save json 保存方法更新 table 的一个变量?我想在另一个中更改一个 value/variable .lua 文件。我该如何做到这一点?
我的main.lua:
local table = {}
table.one = "no"
table.two = "no"
table.three = "no"
loadsave.saveTabe(table, "trying.json", system.DocumentsDirectory)
在check.lua中:
local value = loadsave.loadTable("trying.json, system.DocumentsDirectory)
if( 5+5 == 10)then
value.one = "yes"
--HERE I WANT TO SAVE THE VALUE TO THE SAME JSON FILE WITHOUT CHANGING THE OTHER VALUES/VARIABLES ETC.
end
试试这个:
local value = loadsave.loadTable("trying.json", system.DocumentsDirectory)
if( 5+5 == 10) then
value.one = "yes"
loadsave.saveTable(value, "trying.json", system.DocumentsDirectory)
end