Include path relative to execution directory?
If I want the Script Builder to have include paths be relative to the execution directory, is there a built in way to do this? At the moment they appear to be relative to the script files them selves.
I tried a leading / but it's no good.
At the moment there is no way to do that. However, I have the same needs for my own game engine and plan on making some improvements to the CScriptBuilder to support this.
What I want to do is to allow the application to set callbacks for #include directives. Whenever the CScriptBuilder encounters an #include directive, it would call this callback so that the application can provide the included file based on its own file structure. It should even be possible to provide a pointer to a script in memory, rather than just a file name.
What I want to do is to allow the application to set callbacks for #include directives. Whenever the CScriptBuilder encounters an #include directive, it would call this callback so that the application can provide the included file based on its own file structure. It should even be possible to provide a pointer to a script in memory, rather than just a file name.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
ah that would be great, even making a leading / just remove the base dir from the path might be a good fix to allow for "absolute" paths (relative to the exe).
I maybe be modifying it to do that my self in fact.
I maybe be modifying it to do that my self in fact.
Hey WitchLord, I noticed, you are pretty much doing all the work in ScriptBuilder already, I added 2 lines of code, and now have "absolute" paths working (relative to the exe).
Here is the patch:
If you have:
It doesn't work but:
It does. Thing is, we still want to use a leading slash to signify a path relative to the exe. Which your code already did, so all I do is strip it away if it's an "absolute path" and we are good to go.
Here is the patch:
Quote:
Index: scriptbuilder.cpp
===================================================================
--- scriptbuilder.cpp (revision 418)
+++ scriptbuilder.cpp (working copy)
@@ -289,6 +289,8 @@
{
includes[n] = path + includes[n];
}
+ else
+ includes[n] = includes[n].substr( 1 );
// Include the script section
int r = LoadScriptSection(includes[n].c_str());
If you have:
Quote:
/some/path
It doesn't work but:
Quote:
some/path
It does. Thing is, we still want to use a leading slash to signify a path relative to the exe. Which your code already did, so all I do is strip it away if it's an "absolute path" and we are good to go.
Yes, I saw it, but didn't get a chance to look into it.
I'm not sure this is a solution for everyone. To myself, a path starting with a leading / means that it should be relative to the root of the disk, not relative to the path of the executable.
Anyway, the changes I have planned will allow the application to provide its own way of resolving the paths via a callback. It will even be possible to have includes load from a memory location rather than a file on disk.
Regards,
Andreas
I'm not sure this is a solution for everyone. To myself, a path starting with a leading / means that it should be relative to the root of the disk, not relative to the path of the executable.
Anyway, the changes I have planned will allow the application to provide its own way of resolving the paths via a callback. It will even be possible to have includes load from a memory location rather than a file on disk.
Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement