Charrua Posted May 10, 2021 Share Posted May 10, 2021 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 1 Quote Paren el mundo!, me quiero bajar. Link to comment Share on other sites More sharing options...
Solution Josh Posted May 17, 2021 Solution Share Posted May 17, 2021 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. Quote 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 More sharing options...
Charrua Posted May 17, 2021 Author Share Posted May 17, 2021 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? Quote Paren el mundo!, me quiero bajar. Link to comment Share on other sites More sharing options...
Josh Posted May 17, 2021 Share Posted May 17, 2021 Does your code load the zip file at all? Is the map file inside the zip? 1 Quote 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 More sharing options...
Charrua Posted May 17, 2021 Author Share Posted May 17, 2021 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 1 Quote Paren el mundo!, me quiero bajar. Link to comment Share on other sites More sharing options...
Charrua Posted May 17, 2021 Author Share Posted May 17, 2021 problem solved, is on the workshop for any ho wants to play with. https://steamcommunity.com/sharedfiles/filedetails/?id=2490242870 enjoy Juan Quote Paren el mundo!, me quiero bajar. Link to comment Share on other sites More sharing options...
Recommended Posts
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.