更新解析列。

我刚开始使用 Parse,在我的名为 User 的 parse.com 表格中有一个得分列出了问题。

这里有我的登录函数,用户成功登录后,我有这个函数应该在用户玩游戏时更新得分。

local parse = require( "mod_parse" )
local ego = require "ego"
local saveFile = ego.saveFile
local loadFile = ego.loadFile
--------------------------------------------------------------------
--------------------------------------------------------------------

 _G.score = 1

_G.highscore = loadFile ("highscores.txt")

local function checkForFile ()
if highscore == "empty" then
highscore = 0

saveFile("highscores.txt", highscore)
end
end
checkForFile()

--Print the current highscore
print ("Highscore is", highscore)

-----------------------------------------------
dataTable = { ["score"] = tonumber(highscore) }

function onSystemEvent (event)
if _G.score > tonumber(_G.highscore) then --We use tonumber as highscore is a string when loaded
saveFile("highscores.txt", _G.score)

parse:updateObject( "objectId", dataTable, onSystemEvent )

end
end
 _G.timer1=timer.performWithDelay(100, addToScore, 0)

这些函数将 score 与高分比较,如果 score 高于 highscore,则会使用新值更新 highscore

我在 parse:updateObject 函数方面遇到了问题。在 Parse 上有一个名为 score 的列,我试图使用新的高分更新它。我做错了什么?

点赞
用户4080860
用户4080860

尝试调用 updateObject 方法保存对象,需要知道对象的 objectID

您正在通过调用 updateObject 方法尝试保存对象,我认为这需要您知道您想要保存的对象的 objectID。我猜您尝试使用 "objectId",但那肯定不是正确的 objectID。对此,我无法提供更多帮助,因为我不了解 LUA。

我猜您需要某种 ParseObject,以便保存新行。我建议您查看 Parse SDK,它们非常好地解释了这一点

2015-02-18 02:52:13