Jump to content

[C++] Errors in App lifecycle


Rastar
 Share

Recommended Posts

When running an app from the IDE, the following line in App.Start() (I don't have an App.lua, so it's trying to execute Main.lua)

 

//Invoke the start script
if (!Interpreter::ExecuteFile(scriptpath))
{

 

will throw an error

 

First-chance exception at 0x76C23E28 in MTLighting.debug.exe: Microsoft C++ exception: common::CNamedArgsUndefinedNameException at memory location 0x00CFE7A4.
First-chance exception at 0x76C23E28 in MTLighting.debug.exe: Microsoft C++ exception: common::CNamedArgsUndefinedNameException at memory location 0x00CFE774.

 

The execution jumps out here and continues when stopping the application (Esc) at

 

//Call the App:Start() function
Interpreter::GetGlobal("App");
if (Interpreter::IsTable())

 

in App.Start(), and then executes App.Loop() (which returns right away).

Link to comment
Share on other sites

Mmmmh, it's been a while since I did some programming in Leadwerks, and things seem to have changed slightly... If I see this right, for C++ projects the Main.lua script is executed in App::Start(), which contains the game loop. And when this is ended, the C++ execution continues in App::Start(), then App::Loop() (which basically does nothing). Also, since everything is done in Main.lua, the World, Context, Camera and Window member variables are all null.

 

I can change this according to my needs, but I think for C++ projects there should be a template with a clean lifecycle implementation done in C++. When I choose a C++ project, I prefer to use Lua for encapsulated entity behavior, but use C++ for the heavy lifting in the background.

Link to comment
Share on other sites

The App() approach was implemented for mobile, which is no longer a concern. Lua has moved into a single main.lua file, but for old projects the App.lua file will still be executed in the original manner. The C++ code is still using the App class because changing that would make the documented examples not work.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...