Advertisement

Include path relative to execution directory?

Started by May 26, 2009 03:01 PM
5 comments, last by Wavesonics 15 years, 6 months ago
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.
==============================
A Developers Blog | Dark Rock Studios - My Site
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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
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.
==============================
A Developers Blog | Dark Rock Studios - My Site
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:
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.
==============================
A Developers Blog | Dark Rock Studios - My Site
Just curious, did u see this patch WitchLord? Are you interested in it?
==============================
A Developers Blog | Dark Rock Studios - My Site
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

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
ah ok, sounds reasonable :)
==============================
A Developers Blog | Dark Rock Studios - My Site

This topic is closed to new replies.

Advertisement