hi guys I have a situation whith loadsave functions that I do not understand.
I have a music button created in scene create with a manageMusic “tap” listener
local loadsave = require( "loadsave" ) local myTable = {} local function manageMusic() if audio.getVolume( { channel=1 } ) == 0 and audio.getVolume( { channel=2 } ) == 0 then audio.setVolume( 0.4, { channel=1 } ) audio.setVolume( 0.4, { channel=2 } ) musicBtn.fill = loads.musicOn --save music state to JSON myTable.musicIsOn = true loadsave.saveTable(myTable, "myTable.json") print("Music is on == ", myTable.musicIsOn ) else audio.setVolume( 0, { channel=1 } ) audio.setVolume( 0, { channel=2 } ) musicBtn.fill = loads.musicOff --save music state to JSON myTable.musicIsOn = false loadsave.saveTable(myTable, "myTable.json") print("Music is on == ", myTable.musicIsOn ) end end
-- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then myTable = (loadsave.loadTable("myTable.json") ) print( myTable.musicIsOn )
When I load “myTable.json” and print variables with numeric values I get the numbers printed but when I print a boolean the output is nil :huh:
Thanks in advance
DoDi