Debugging while incorporating the Director Class

I’m very green at using Corona, that being said, I’m having a really hard time using the director class for the following reason:
I get how to make the calls, and can usually get a bit of progress in switching from my main menu to the game, AND the implementation of the error messages I get in the console are awesome, however I’m making the mistakes, and how do I get the console to display my errors, rather than just the generic

Director Error: failed to load module ‘game’ please check if the file exists and is correct.

I know I’m breaking it every time, but how do I get the simulator to give me a line number in my code so I’m not guessing, when I’m using the director class?

Do I need to build the whole game state seperately, and at the end of development, incorporate Director?

Ideas, anyone?
TIA
[import]uid: 7382 topic_id: 12073 reply_id: 312073[/import]

Biffo, you should definitely integrate with Director sooner than later for this precise reason - you can check it along the way. IMHO it’s much harder to put your code into Director after the fact, than right out of the gate. You are doing exactly what you need to be doing. As for getting more debugging results you can still run your app via the Corona Terminal and spit out anything you want using print statements…

Like this:

 print("Something meaningful to your debugging efforts, variable values, line numbers, whatever")  

You can sprinkle those in anywhere to help with debugging and view in the Terminal window as you are running and debugging.

I’m also rolling an app into 1.3 tonight, the new version is looking great. Ricardo did a great job!

Some other tips that will keep you from punching the screen…

  • Remember to have images you are using in your project folder, it’s easy to get going copying and pasting and not have resources that are needed to load

  • Remember to get ALL your display objects into that localGroup

  • Read the second bullet again

  • Don’t be afraid to modify and/or add print statements into the Director.lua file to help paint the picture of what is going on, Ricardo will probably be thrilled you are in there and besides you can always get back to the original easy enough if you crash the universe

Good luck! I’m in there too!

One thing I added into my Director.lua file for some development stages was this function…

local function ShowDetails()  
  
 -- print memory usage  
 local memUsage\_str = string.format( "memUsage = %.3f KB", collectgarbage( "count" ) )  
 print( memUsage\_str )  
 local texMemUsage\_str = string.format( "texMemUsage = %.3f KB", system.getInfo( "textureMemoryUsed" ) )  
 print( texMemUsage\_str )   
end   

I call it like this inside the director:changeScene, right after the isChangingScene evaluation:

 print("Before Scene Change - Director")  
 ShowDetails()  

And once again like this in the last lines of executionof the director:changeScene

 print("After Scene Change - Director")  
 ShowDetails()  

Then I just watch the terminal as I keep adding stuff to my Scenes to see how bloated the texture map and memory usage gets - it kind of creates a todo list for me of things to optimize so to speak.

Hope any of that is helpful…

–Croisened [import]uid: 48203 topic_id: 12073 reply_id: 43989[/import]

Hey guys, I’m already working on a better error message and a boolean variable to toggle it on/off.

Thanks,

Ricardo Rauber [import]uid: 8556 topic_id: 12073 reply_id: 44026[/import]

Thanks Ricardo! And ty croisened for the idea. I could do that, but I really depend on that console widow telling me what line number, my logic’s breaking down at. I don’t want to mess with Ricardo’s director class, unless I really get it all. BTW Ricardo, I tried a couple of times to donate to you but the redirect from your blog takes me to a spanish paypal that won’t accept my password. (It’s a bit unnerving entering in payment info on a page I can’t read.) Do you want to add a link to an english paypal? I did send 10.00 to ricardorauber@gmail.com, and I truly appreciate your sharing this awesome lib.
[import]uid: 7382 topic_id: 12073 reply_id: 44092[/import]

Hey Biffo, try changing this on Director:

--====================================================================--  
-- TOGGLE DEBUG  
--====================================================================--  
  
showDebug = true  
--showDebug = false  
  
--====================================================================--  
-- SHOW ERRORS  
--====================================================================--  
  
local showError = function( errorMessage, debugMessage )  
 local message = "Director ERROR: " .. tostring( errorMessage )  
 local function onComplete( event )  
 print()  
 print( "-----------------------" )  
 print( message )  
 print( "-----------------------" )  
 print( debugMessage )  
 print( "-----------------------" )  
 error()  
 end  
 --  
 if showDebug then  
 local alert = native.showAlert( "Director Class - ERROR", message, { "OK" }, onComplete )  
 else  
 onComplete()  
 end  
end  

On the pcall() executions, change to something like this:

local handler, message = pcall( nextScreen.clean )  
--  
if not handler then  
 showError( "Failed to clean object '" .. nextScene .. "' - Please varify the localGroup.clean() function.", message )  
 return false  
end  

Donation was in portuguese, I think now it’s fixed. Thanks a lot for your contribution! [import]uid: 8556 topic_id: 12073 reply_id: 44113[/import]

Awesome! Thanks Ricardo. I’ve been building the gamestate seperately to work out the kinks and then incorporating into the scen based version as I get the code semi solid. This should help though. Thanks for the awesome tool!

[import]uid: 7382 topic_id: 12073 reply_id: 44127[/import]