Road Kill Kenny Posted October 15, 2012 Share Posted October 15, 2012 Hi all, A video can explain this issue much better so see below...... This issue is just very very strange and I was wondering if anyone has come across it before and if there is a solution. Enjoy the easter eggs. Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
Daimour Posted October 15, 2012 Share Posted October 15, 2012 It would be nice to see that LUA-script and that error message. Source code must say much more than video in this case. I think something wrong with paths. Try to replace relative path to script "scripts/class" with abstract one "abstract::class". Quote Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted October 15, 2012 Author Share Posted October 15, 2012 It would be nice to see that LUA-script and that error message. Source code must say much more than video in this case. I think something wrong with paths. Try to replace relative path to script "scripts/class" with abstract one "abstract::class". The error is: "can't open scripts/class" The paths should be irrelevant as it works In all other instances as shown in the video. However, I did try abstract::class instead to no avail. If the path is the problem then It doesn't make sense that it will work one second and not the next.... with the exact same LoadModel() function call. There is no point showing you the script itself because there is nothing wrong with it. The exact same script works in the editor and in the actual game and strangely when I add objects in the editor but not when I load a level with the editor..... Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted October 15, 2012 Author Share Posted October 15, 2012 Ok so here is the source code that matters. I'm rather certain it is all correct but I'll show you anyway: LE::TFramework fw = CreateFramework(); if(!fw) MessageBoxA(NULL, "Error 03: Failed to Create Framework", "Error LE-03", MB_OK); LE::SetAppTitle("Level Editor"); LE::RegisterAbstractPath(K_Win::GetAppPath().c_str()); //K_Win::GetAppPath() returns the path to the folder of the .exe application file. //Lua Setup LE::BP lua = LE::GetLuaState(); LE::lua_pushobject(lua, fw); LE::lua_setglobal(lua, "fw"); LE::lua_pop(lua, 1); Loading of the model in both instances. Note that I don't use abstract path in the C++ code at all anymore. So these arguments that may look foreign are simply absolute paths. //This is how it is called when loading a scene gateModel = LE::LoadModel((lvlDat->gameDir + lvlDat->csGatePath.at(CS_ID)).c_str()); //And this is how it is called when simply adding to the scene gateModel = LE::LoadModel((lvlDat->gameDir + lvlDat->csGatePath.at(CS_ID)).c_str()); Yes they are indeed exactly the same and the arguments calculate to be the exact same path as well granted that CS_ID is the same. These are called within a Gate class in the constructors. It has a constructor for loading from database (DDD) and a non DDD constructor for when you want to add one to the scene with default settings. They only differ slightly and in no way do they effect this LoadModel() function call. Both the game and the editor work straight out of the same folders too.. so I really have ran out of things that I can think of even trying to do that will solve this. Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
Rick Posted October 15, 2012 Share Posted October 15, 2012 Just for another test, have you tried using abstract paths to see if it works? I understand what you are saying, but it's another option to at least test and see if the results are as you would expect. Quote Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted October 15, 2012 Author Share Posted October 15, 2012 Yes I have, no difference.... It's still a mystery as to why it works when adding to scene and not when loading file. I think this is going to come down to a workaround rather than a solution. Just thought I'd check in see if anybody has ever experienced this. Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
Pixel Perfect Posted October 15, 2012 Share Posted October 15, 2012 I get this error message frequently 'can't open scripts/class' in some of my builds, the bad news is it tends to be intermittent and I have never found a solution to it yet, not that I have been using Lua for long. My Leadwerks to EKI One executable always displays this error and my current Neutrino Engine Editor sometimes throws this error and other times doesn't; and that's on consecutive runs! In both cases the scripts directory is in the root of the application. I would be very interested to find the reason behind this too. Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Rick Posted October 15, 2012 Share Posted October 15, 2012 I have to imagine it's something to do with the setup you guys have. I have never had this error other than not having the scripts folder in the same dir as the running exe. I'm pretty sure I also never use RegisterAbstractPath() function as it must default to the exe dir and subdirs if you don't call it. Quote Link to comment Share on other sites More sharing options...
ChrisMAN Posted October 15, 2012 Share Posted October 15, 2012 Is the current working directory correct? I got that error because I was pushing all of my binaries to a separate folder. I made a bat file to launch the game ./bin/game.exe Lua uses a special variable to see where the loading paths are. http://lua-users.org/wiki/PackagePath That could give you insight. Quote Link to comment Share on other sites More sharing options...
Pixel Perfect Posted October 15, 2012 Share Posted October 15, 2012 Is the current working directory correct? I got that error because I was pushing all of my binaries to a separate folder. I made a bat file to launch the game ./bin/game.exe Lua uses a special variable to see where the loading paths are. http://lua-users.org/wiki/PackagePath That could give you insight. Thanks ChrisMAN, I'll take a look at that. Regarding my executables, yes I do the same, I build to debug and release sub directories but this occurs when the executable has been copied to the root directory of the application which contains the scripts directory! Clearly something is causing this, I've just not isolated it yet! Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
macklebee Posted October 15, 2012 Share Posted October 15, 2012 Abstract paths do not work with the lua 'require', hence the fact you have to have the 'Scripts' folder located within your project to access the class script. The only thing that I could suggest is to have the Scripts folder be located in your editor's executable folder and have a reference to require it in 'Start' folder. I have never gotten this error either unless my project folder was missing the 'Scripts' folder. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted October 15, 2012 Author Share Posted October 15, 2012 This is why it is wierd guys... I've done this plenty of times before scripts folder is in the right place. Abstract path is not the problem... Even if I remove that line it still does the same thing. The binaries are ain the same folder as scripts folder.. no separate folders. The paths are correct.... If they weren't it wouldn't work ever.... not just in this one instance when loading a scene. That is what makes this problem strange. Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
Daimour Posted October 16, 2012 Share Posted October 16, 2012 Ok so here is the source code that matters. I asked about LUA-script which invokes "scripts/class". How does it do? With require command? It must be somewhere in your attached to model "gate.lua" file I suppose. I can assume only that this two cases use LUA environment with different states. And search path may be changed. You can check search path in than lua script: AppLog(package.path) Add this line right before "scripts/class" invoking. And watch the LOG-file. For both cases. 1 Quote Link to comment Share on other sites More sharing options...
Pixel Perfect Posted October 16, 2012 Share Posted October 16, 2012 I'm pretty sure in my case I don't have multiple Lua states but that code will be useful to see where it thinks it's looking for the scripts when these errors occur. Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted October 16, 2012 Author Share Posted October 16, 2012 I asked about LUA-script which invokes "scripts/class". How does it do? With require command? It must be somewhere in your attached to model "gate.lua" file I suppose. I can assume only that this two cases use LUA environment with different states. And search path may be changed. You can check search path in than lua script: AppLog(package.path) Add this line right before "scripts/class" invoking. And watch the LOG-file. For both cases. Will try this when I get home\ Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted October 17, 2012 Author Share Posted October 17, 2012 Tried the AppLog(pagage.path) thing and it was identical in both instances. Abstract paths do not work with the lua 'require', hence the fact you have to have the 'Scripts' folder located within your project to access the class script. The only thing that I could suggest is to have the Scripts folder be located in your editor's executable folder and have a reference to require it in 'Start' folder. I have never gotten this error either unless my project folder was missing the 'Scripts' folder. Thanks, for this work around mack.... I put the class script in the start folder and because it loads it at start up it works... .It still throws the error when loading the scenr but it should do the trick for now. Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
Daimour Posted October 17, 2012 Share Posted October 17, 2012 Abstract paths do not work with the lua 'require' It works very well for me. But I write my game entirely in LUA. require("abstract::core") require("abstract::filesystem") require("abstract::string") require("abstract::vector") require("abstract::properties") 1 Quote Link to comment Share on other sites More sharing options...
Daimour Posted October 17, 2012 Share Posted October 17, 2012 Could that "Open file..." window change current working directory? Try to load a scene with hardcoded path without opening dialog. Quote Link to comment Share on other sites More sharing options...
macklebee Posted October 17, 2012 Share Posted October 17, 2012 It works very well for me. But I write my game entirely in LUA. Then this has changed without notice because it had not in the past and was repeatedly stated as such from the developer. And from what I just checked with my older versions of LE, this did not work until LE2.42. This would have been good information to know. But this is good news, so thanks for the information, Daimour! Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted October 17, 2012 Author Share Posted October 17, 2012 Could that "Open file..." window change current working directory? Try to load a scene with hardcoded path without opening dialog. It is impossible for this to change the path for LUA... All the open file thing is is a function that uses the Win32 API to get an open file dialog box which returns a std::string static std::string K_Win::FileOpen(){ OPENFILENAME ofn; char fileName[MAX_PATH] = ""; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = NULL; ofn.lpstrFilter = "SQLite3 Files (*.*)\0*.*\0"; ofn.lpstrFile = fileName; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrDefExt = ""; std::string fileNameStr; if(GetOpenFileName(&ofn)) fileNameStr = fileName; return fileNameStr; } And the it is simply called like this lvlDat->SetLoadFile(K_Win::FileOpen()); The lvlDat is a LevelData* class and it has no ability to change the abstract path or any other path. SetLoadFile simply changes a std::string variable in the LevelData class that is then used to open an SQLite Database and query it. Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
Daimour Posted October 17, 2012 Share Posted October 17, 2012 Look here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646927%28v=vs.85%29.aspx Pre-last comment. 2 Quote Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted October 17, 2012 Author Share Posted October 17, 2012 Look here: http://msdn.microsof...7(v=vs.85).aspx Pre-last comment. Hmm very interesting.... and rather annoying that it changes the directory. Not sure why it does, I can't see any value in changing the working directory considering the GetOpenFileName() function returns an absolute path and not a local file name. Thanks for the info. I should be able to solve it based on that info If I use SetCurrentDirectory() immediately after GetOpenFileName() to change the directory back to the default directory then it should work. http://msdn.microsof...0(v=vs.85).aspx Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
Pixel Perfect Posted October 18, 2012 Share Posted October 18, 2012 When the user selects at least one file and clicks the OK button, the process' current working directory is changed to the directory contain the file(s) being opened. Many thanks Daimour, this definietely explains why it's happening in one of the the cases I was experiencing and quite possibly in both. It only happens in apps that have file open dialogs so it looks highly likely! Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted October 18, 2012 Author Share Posted October 18, 2012 Yes thanks a lot Daimour. It works perfectly now. Never would have thaught the win32 Api function call had anything to do with it lol. Here's the new code for that function, works the charm static std::string K_Win::FileOpen(){ OPENFILENAME ofn; char fileName[MAX_PATH] = ""; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = NULL; ofn.lpstrFilter = "SQLite3 Files (*.*)\0*.*\0"; ofn.lpstrFile = fileName; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrDefExt = ""; std::string fileNameStr; char curDir[MAX_PATH]; GetCurrentDirectory(MAX_PATH, curDir); if(GetOpenFileName(&ofn)) fileNameStr = fileName; SetCurrentDirectory(curDir); return fileNameStr; } Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
Daimour Posted October 19, 2012 Share Posted October 19, 2012 That was just accidental lucky guessing. I suggest to rename topic to something like "error can't open scripts/class" for better searching possibilities. Quote 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.