WHY I HAD THOUGHT THIS DIDN’T WORK (previously)
Remember my comment at the beginning of the week that my print statements weren’t outputting with logcat?
I had actually tried two things to test the globalizing of cached_displayNewGroup and both failed in my test/
FIRST THING TRIED
THIS FAILS IN THE SIMULATOR:
-
Place “widget.lua” in the main project directory next to “main.lua” with the variable set to be global.
-
Place this code in “main.lua” to test it all in the simulator:
widget = require(“widget”)
if (cached_displayNewGroup) then
print ("########### MAIN (widget.lua next to main) - cached_displayNewGroup is NOT nil")
function display.newGroup()
return cached_displayNewGroup()
end
else
print ("########### MAIN (widget.lua next to main) - cached_displayNewGroup IS NIL")
end
-
When I run this, NONE of the print statements in “widget.lua” (see previous post) actually display (as widget is birthed) and cached_displayNewGroup is nil when I test for it.
-
But, on the other hand, I know that the code in “widget.lua” actually did run (or the Widget code ran somewhere else) – it managed to hose the removeSelf() functionality of any dispely groups I tried to subsequently remove.
-
After this essentially failed in the simulator, I didn’t think to try it fully on a build for the device (I should have)
=============================================================================
And another bit of simulator “voodoo”. If I change the name of the lua file
to “widget1.lua” and instantiate with this:
widget = require(“widget1”)
Then everything runs just fine with all print statements firing and
cached_displayNewGroup is NOT nil!
I think I know what you are doing here, I just think it is strange that you
don’t document it anywhere. It will waste someone else’s hours down the road.
=============================================================================
====== CONTINUED BELOW ========================================================================