Wow, it gets stranger. If I comment out line 10 above ( gameNetwork.show( “leaderboards” ) ) the loggedIntoGC value remains true. What in gameNetwork.show could possibly be wiping out my boolean?
So I can get it to work by doing the following (where loggedIn is a local to menu.lua):
[lua]
local function showGameCenter(event)
if (loggedIn == nil) then
loggedIn = storyboard.loggedIntoGC
end
if (loggedIn) then
if (system.getInfo(“platformName”) == “Android”) then
gameNetwork.show( “leaderboards” )
else
gameNetwork.show( “leaderboards”, { leaderboard={ category=“highscore”, timeScope=“Week” } } )
end
[/lua]
In other words, saving away the original global in a local remembers the setting. Don’t like this at all and I wish I could figure out what the root cause was.
Weird
@Rob Ya, I wish I had an explanation… I’ve put logging EVERYWHERE that storyboard.loggedIntoGC is set and it’s only set to TRUE once during initialization. But unless I save it away in the local variable, it gets lost. I might be misunderstanding something about the Lua language. I’ll post if I find anything further out.
I can see the gameNetwork module changing a global but there is no reason for it to be modifying anything in the storyboard object. Have you tried renaming the variable to something else?
yes, I’ve tried renaming it with no difference
If you’re renamed it to something else, then your code is resetting it somewhere. The chances of a module hitting two different variable names is pretty slim and since you are also putting it in another table too, that would protect against any globals, so what’s left is something in your code resetting it.