loadsave boolean value nil, help!

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

Can you do a:

print( json.prettify( myTable ) )

and share the results?

Rob

19:36:24.110 File found: myTable.json 19:36:24.110 { 19:36:24.110 "livesNumber":2, 19:36:24.110 "sceneNumber":"8" 19:36:24.110 }

no musicIsOn true or false

I see that the problem is every time a value is saved in “myTable”, “myTable” is deleted and replaced by a new .json file. I have managed to write the current level number and the current lives number satisfactorily to “myTable” because those values ​​are present and are updated in all the scenes. However I can not see how to write the value of “musicIsOn” through the scenes. It is a simple game to try everything I could learn from “Corona SDK”. I understand that I must pass the value of “true” or “false” to the scenes for each time “myTable” is written, “musicIsOn” value be saved too, but…

I do not know how to do it.

Thanks in advance
DoDi

I don’t know that I can tell enough from your code snippets to get a full context of where myTable is and isn’t in scope. JSON supports boolean values so it doesn’t make sense that your true/false values are not being saved.

It would useful for you to go into the loadsave module and print the string being read from the file before it gets decoded to see what the JSON content actually is.

Rob

I think I found a way to destroy all scenes and make a full save of .json table, but I’m re-writting my 10 levels.

The 

print( json.prettify( myTable ) )

was very very useful, thanks @Rob…If I make another mistake I will comment here.

Can you do a:

print( json.prettify( myTable ) )

and share the results?

Rob

19:36:24.110 File found: myTable.json 19:36:24.110 { 19:36:24.110 "livesNumber":2, 19:36:24.110 "sceneNumber":"8" 19:36:24.110 }

no musicIsOn true or false

I see that the problem is every time a value is saved in “myTable”, “myTable” is deleted and replaced by a new .json file. I have managed to write the current level number and the current lives number satisfactorily to “myTable” because those values ​​are present and are updated in all the scenes. However I can not see how to write the value of “musicIsOn” through the scenes. It is a simple game to try everything I could learn from “Corona SDK”. I understand that I must pass the value of “true” or “false” to the scenes for each time “myTable” is written, “musicIsOn” value be saved too, but…

I do not know how to do it.

Thanks in advance
DoDi

I don’t know that I can tell enough from your code snippets to get a full context of where myTable is and isn’t in scope. JSON supports boolean values so it doesn’t make sense that your true/false values are not being saved.

It would useful for you to go into the loadsave module and print the string being read from the file before it gets decoded to see what the JSON content actually is.

Rob

I think I found a way to destroy all scenes and make a full save of .json table, but I’m re-writting my 10 levels.

The 

print( json.prettify( myTable ) )

was very very useful, thanks @Rob…If I make another mistake I will comment here.