Jump to content
Rastar

[C++] Errors in App lifecycle

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).

Share this post


Link to post

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.

Share this post


Link to post

Yeah for the C++'ers it's annoying now how things are setup. If I work in a C++ project I usually gut all the C++ code that's there and start from scratch with my own setup.

Share this post


Link to post

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.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

×
×
  • Create New...