Skip to content

Instantly share code, notes, and snippets.

@madclaws
Created April 23, 2018 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madclaws/2a812b50f085acf3bdd901451d893cd0 to your computer and use it in GitHub Desktop.
Save madclaws/2a812b50f085acf3bdd901451d893cd0 to your computer and use it in GitHub Desktop.
storing playerdata
function helper.writePlayerData(_playerID,_color)
-- local curCount
local curCount=fetchCount()
print(curCount.current)
print(_playerID .. " : " .. _color)
local new_record={
{Bucket=_bucket,Collection="GamePlay",Record="playerData",Value={id=curCount.current,color=_color}}
}
if curCount.current<1 then
nk.storage_write(new_record)
else
local updateOps={
{Op="append",Path="/",Value={id=curCount.current,color=_color}}
}
local updateRecord={
{Bucket=_bucket,Collection="GamePlay",Record="playerData",Update=updateOps}
}
nk.storage_update(updateRecord)
end
updateCount(curCount.current)
fetchPlayerData(_playerID)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment