OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Fragorl on 07 Sep 2005, 10:17:12
-
Maybe I'm doing something stupid, maybe not. Either way, I'm getting this error message:
"script FRG_Addon\functions\myFunction.sqf not found"
This is when I have the following in my addon's initialisation script:
_function = preprocessFile "\FRG_Addon\functions\myFunction.sqf"
However, if I change it to read
_function = loadFile "\FRG_Addon\functions\myFunction.sqf"
(ie exactly the same but with loadfile) then it works fine. The function itself has no comments, neither the // and /**/ variety, nor the comment{}; variety. I had a brief check of the comref to see if this was a known problem, but nothing at all could I see.
Any help appreciated.
-
OFP 'feature' (another BISd function)
preprocessFile does not support 'paths' to external pbos/locations (in lack of better terminology which Mikero will correct later on :) :P )...
It only works in missions when the sqf to be preprocessed is in the same pbo (haven't tried subfolders in mission pbo)...
preprocessFile also works if the sqf is located in the dta\scripts.pbo and in a subfolder in it (scripts.pbo)...
Sometimes when you use
_function = preprocessFile "..\FRG_Addon\functions\myFunction.sqf"
may work, I have not had the luxury but others have...
EDIT:
Afaik you don't 'lose a thing' when you use loadFile instead of preprocessFile...
-
Cheers HateR :D
Yes, this is part of an addon, which explains why I was so confused that it worked in a test mission but not in the other situation ... :P the only reason I was using preprocess is to remove \\ and \* comments.
I will give the double dots "..\" a go. This normally means 'down directory' in dos-speak, doesn't it?
Anyhow, if nothing else works, I will simply switch over to loadfile and do away with comments ... which is a bugger, but if I have to then I will.
Btw, this would have been in the bugged/bis'd commands thread, wouldn't it? I didn't think to look there. Anyhow, will post a comment in the comref about this once I test it tonight. Thanks for the help.
-
I will give the double dots "..\" a go. This normally means 'down directory' in dos-speak, doesn't it?
I have no clue :P
Seen it used in C++ #include etc. though...
This thing was revealed to me by the 'great MP mastah' Killswitch, btw, so it's not my find... :)
Btw, this would have been in the bugged/bis'd commands thread, wouldn't it?
I don't think this particular thing is actually mentioned there..
But me memory can fail me... :)
-
Yep, one can use preprocessFile in an addon. Just remember this:
- As mentioned, the filename must be "..\MyAddon\something.sqf" instead of just "\MyAddon\something.sqf"
- Due to yet another bug in the dedicated Linux server software, such an addon will not work there unless you create an empty folder named "scripts" in your Linux ofp server installation folder.(*)
If you don't understand the second point there and the implications it has with regards to documenting and supporting your addon properly, please use loadFile instead.
(*) It's due to a path separator parsing bug - the person responsible for the Linux code was inconsistent in remembering to accomodate for the fact that in Unix, the path separator is the forward slash and in Windows the backward one.
-
Unfortunately I'm having no luck with this approach, perhaps because I have the function in question in a further directory:
\MyAddon\Functions\Function.sqf
I've tried every possible approach (I think) to get it to work, short of dumping the functions straight into the addon folder, which I'm not prepared to do. Looks like I'll have to settle for removing all comments and using loadfile :-\
-
Well, you don't lose much if you are not using comments...
It seems that not many open up the script parts of AddOns, they're more interested in the textures/models... ::)
You can always include a text version (.txt, not .sqf) which has the comments in case someone happens to be interested...