Jump to content

Standalone UAK+Leadwerks crash


Charrua
 Share

Go to solution Solved by Josh,

Recommended Posts

Hi, much time from my last post :(

I have been testing UAK and Leadwerks, al right from VS running release and debug versions and from Leadwerks editor. 

I decided to publish a standalone, just for testing and it crashes. I guess that the problem is when I try to call a map entity´s function from cpp.

If I place de uak1.debug.exe in the published folder, the last System:Print i saw is: "scanning entities":

 

System::Print("scanning entities ...");
    for (auto iter = world->entities.begin(); iter != world->entities.end(); iter++)
    {
        Entity* entity = *iter;
        if (entity->GetKeyValue("name")!="") {
            System::Print(entity->GetKeyValue("name"));
            if (hasFunction(entity, "dayNightTest")) {
                System::Print(" found entity dayNight");
                dayNight = entity;
                //dayNight->CallFunction("dayNightTest");
            }
        }
    }

The function "hasFunction" test if an entity has or not a particular function defined and I guess the problem is there, not shure and do not know why.

I commented the line: dayNight->CallFunction("dayNightTest"); because the "dayNightTest" function only has a System:Print on it, for debugging purposes.

 

bool hasFunction(Entity* e, string funcName) {

    if (e->component == NULL) return false;
    bool success = false;

    //Get the component table
    int stacksize = Interpreter::GetStackSize();

    //Get the global error handler function
    int errorfunctionindex = 0;
#ifdef DEBUG
    Interpreter::GetGlobal("LuaErrorHandler");
    errorfunctionindex = Interpreter::GetStackSize();
#endif

    e->Push();
    Interpreter::GetField("script");  //test if entity has a script
    if (Interpreter::IsTable())
    {
        System::Print(" entity has script");
        Interpreter::GetField(funcName);
        if (Interpreter::IsFunction())  //test if funcName is a function
        {
            System::Print("       " + funcName + " defined");
            success = true;
        }
        else {
            success = false;
            System::Print("       " + funcName + " not defined");
        }
    }

    Interpreter::SetStackSize(stacksize);  //keep stack under control

    return success;

}

 

Link the complete project (zip file): https://drive.google.com/file/d/1OWD4I8zAEZsLyKPOAl53VNTACxwyj4yR/view?usp=sharing

 

BTW, it creates slider for the many controls the dayNight prefab has, here a picture of it running:

 

 

Thanks in advance

Juan

 

  • Thanks 1

Paren el mundo!, me quiero bajar.

Link to comment
Share on other sites

  • Solution

What you can do in this situation is change the working directory in the VS project settings to your standalone game's folder and then compile and run like normal. Doing this I was able to determine that the dayNight entity is NULL in the standalone.

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

Thank´s

I did that and found that it can not load the map!

	bool mapOk = false;
    mapOk = Map::Load("Maps/start.map");
    System::Print(mapOk);

so, no entities, no sun, no nothing :(

ir runs ok form vs and leadwerks editor, any ideas?

Paren el mundo!, me quiero bajar.

Link to comment
Share on other sites

forgot it!

I started with the uak sample code, then load a map, etc

but the standalone needs this:

 //Load any zip files in main directory
    Leadwerks::Directory* dir = Leadwerks::FileSystem::LoadDir(".");
    if (dir)
    {
        for (int i = 0; i < dir->files.size(); i++)
        {
            std::string file = dir->files[i];
            std::string ext = Leadwerks::String::Lower(Leadwerks::FileSystem::ExtractExt(file));
            if (ext == "zip" || ext == "pak")
            {
                Leadwerks::Package::Load(file);
            }
        }
        delete dir;
    }

which i forgot!

thanks for your help!

Juan

  • Haha 1

Paren el mundo!, me quiero bajar.

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