ID:154672
 
I have a code file two directories in from the root.
".\blah\blarg\code.dm"

I have icon files referred to in the code file in a different folder in a different folder in the root.
".\bloo\blee\icon.dmi"

How do I set FILE_DIR in the code to reach the icons?
// This is how I would expect to be able to,
// but it doesn't work. (cannot find file error)

// code.dmi
#define FILE_DIR ".\bloo\blee"

obj/icon = 'icon.dmi'

// maybe this is necessary to keep the compiler cleaner?
#undef FILE_DIR


I figure doing this at the top of my code files would make it easier for the compiler. It doesn't have to look through every folder for every icon, just the folder I specify in the code file.
Kaiochao wrote:
I have a code file two directories in from the root.
".\blah\blarg\code.dm"

I have icon files referred to in the code file in a different folder in a different folder in the root.
".\bloo\blee\icon.dmi"

How do I set FILE_DIR in the code to reach the icons?
> // This is how I would expect to be able to,
> // but it doesn't work. (cannot find file error)
>
> // code.dmi
> #define FILE_DIR ".\bloo\blee"
>
> obj/icon = 'icon.dmi'
>
> // maybe this is necessary to keep the compiler cleaner?
> #undef FILE_DIR
>

I figure doing this at the top of my code files would make it easier for the compiler. It doesn't have to look through every folder for every icon, just the folder I specify in the code file.

obj/icon = '\bloo\blee\icon.dmi'
In response to Prf X
Prf X wrote:
obj/icon = '\bloo\blee\icon.dmi'


I forgot to mention, I don't like the idea of doing that for every single object, which is why I want to utilize FILE_DIR (or at least, what I understand it to do).
In response to Kaiochao
Kaiochao wrote:
Prf X wrote:
obj/icon = '\bloo\blee\icon.dmi'

I forgot to mention, I don't like the idea of doing that for every single object, which is why I want to utilize FILE_DIR (or at least, what I understand it to do).

You can try
#define IF "\bloo\blee"//IF = IconFile
In response to Prf X
I'm not looking for a workaround; especially not one that doesn't work.
In response to Kaiochao
Setting FILE_DIR only works inside of the dme file if I recall correctly and it can only have one value. Should be noted that setting it will DRAMATICALLY increase the compile-time for your project.
There's no need to specify to start from the root dir in FILE_DIR because it always starts there. You just need to specify at which subfolder it needs to start searching and how deep it must go.

#define FILE_DIR bloo/blee
obj/icon = 'icon.dmi'
#undef FILE_DIR


An interesting thing about #undef FILE_DIR that I have found is that it seems to only pop off the last file directory that you have specified for the code to look in. For example:

#define FILE_DIR icons
#define FILE_DIR icons/mob
#undef FILE_DIR
icon = 'player.dmi' //player.dmi is in icons no error here
icon = 'monster.dmi' //monster.dmi is in icons/mob there is an error here
#undef FILE_DIR
icon = 'player.dmi' //player.dmi is in resource file so it doesn't need to look through file directories. No error or warning even though the compiler shouldn't be able to find it outside the rsc.


Furthermore when messing with defining and undefining FILE_DIR it doesn't seem to warn you when the icon is only found in the resource file any more.
In response to Nadrew
No, it's set up to read multiple values in a LIFO structure. When you undef a file directory the last defined file directory is removed. The only FILE_DIR set in the DME is to tell the compiler to always start searching from the root folder. I also don't think you can pop off the initial FILE_DIR setting because it's defined in the DME (even the DME itself tells you not to mess with BEGIN-END blocks and the first FILE_DIR definition is inside one of those).

Furthermore, I don't believe it should dramatically increase compile time because most projects have the compiler automatically set the file directories for them and thus the compiler searches through ALL subfolders until it finds a resource. By setting it manually wouldn't it allow you to tell the compiler to hone in on certain folders and thus save a bit of compiling time?
In response to BrickSquadron
With FILE_DIR disabled outright (done through your project preferences) and using full paths when you reference a file you pretty much save the time taken to search through your directories. In the cases of larger projects this can mean the difference between a 30-second compile-time and a 15-minute compile-time.
In response to Nadrew
Nadrew wrote:
With FILE_DIR disabled outright (done through your project preferences) and using full paths when you reference a file you pretty much save the time taken to search through your directories. In the cases of larger projects this can mean the difference between a 30-second compile-time and a 15-minute compile-time.

If it could make that big of a difference, I have to imagine that you're not using icon files effectively (ex: you have tons of icon files with one state instead of one file with many states) and that Dream Maker is terribly inefficient. I could probably iterate over all files on my hard drive in 15 minutes. If DM can't search a few folders in under a minute it should be reported as a bug (if it hasn't already).