[ZeroBrane Studio] Re: Remote debugging: IDE project path vs. actual file path

  • From: jan@xxxxxxxxxxx
  • To: zerobrane@xxxxxxxxxxxxx
  • Date: Thu, 23 Oct 2014 10:36:00 +0200

Correct. The simplest solution is to run the script from the same
folder that you set as Project folder in the IDE. Is there any reason
why you can not run it from scripts/ folder (or whatever folder your
Project folder is set to)?


One reason is that all the asset paths are relative to the current running directory. Those could be changed, but I also want our application to be "runnable" by just executing it from the location it is in.

If you do need to run it from the folder with the executable, can you
make sure that you are loading your script that includes
"require('mobdebug').start()" call using relative instead of an
absolute path? For example, instead of "myapp.exe
d:\gamedir\scripts\main.lua" use "myapp.exe ..\..\scripts\main.lua".
ZBS will attempt to remap the remote path and the project path in the
IDE and you may see a message "Mapped remote request for '...' to
'...'." in the Output window.


Well, what I basically do is manually assembling and executing this line of code FROM WITHIN C++:
Mods.rogueassembly = require(rogueassembly.init)
Which only works because ../../scripts/?.lua was added to the package path. I would love to require() using a relative path, but afaik that is not possible. Dofile is possible using relative paths, I think, but does not offer the same functionality as require.

I think the biggest problem here is that ZBS expects the script/project directory to be the same as the running directory, which is very likely not true for the majority of applications that have Lua embedded. Most games I know have a seperate scripts folder that is NOT the running directory. Another issue is that we want to allow modding by putting mods into a folder in the user directory, so this user directory will also have to be added to the package path.

The only real solution I see here is to make it possible to change what ZBS expects. For our case, it would be the best if ZBS had an array of paths it would accept that can lead to "rogueassembly/init.lua": Its normal path (not sure what that actually is if the scripts folder is set as the project folder in ZBS), "../../scripts" and probably a full path to said user directory. I really do not know how we could make it work otherwise.

Is this possible somehow with a plugin, maybe?

Or are there any other ways to resolve this? Maybe a custom require that does accept relative paths or something like that. Or if this is a part of mobdebug, just modify mobdebug.lua as we distribute it with the application anyway.



Other related posts: