Reputation: 75
I have a function, which changes the variable from what it was to something new. I am using load-save .json tables to get and load data. How do I update the startmoneyTxt to display the new variable?
My function:
local function unlockBall(event)
ballfirst = loadsave.loadTable("firstBall.json", system.DocumentsDirectory)
currentMoney1 = loadsave.loadTable("cashTable.json", system.DocumentsDirectory)
difference = currentMoney1 - ballfirstUnlock
if(ballfirst == 0 and difference >= 0)then
ballfirstID = 1
loadsave.saveTable(ballfirstID, "firstBall.json", system.DocumentsDirectory)
loadsave.saveTable(difference, "cashTable.json", system.DocumentsDirectory)
end
end
My code which should be updated:
currentMoney = loadsave.loadTable("cashTable.json", system.DocumentsDirectory)
startmoneyTxt= display.newText("$ "..currentMoney.." " , 0,0, "Helvetica", 20)
sceneGroup:insert(startmoneyTxt)
Upvotes: 0
Views: 122
Reputation: 1702
Whenever you want change text use
startmoneyTxt.text = "Your text here"
Note: As names saveTable
and loadTable
imply functions are indent to save/load tables. So you can use one file to save/load multiple values.
I use loadsave module to save/load setings in my game The Great Pong.
Upvotes: 1