I'd say that you allow .zips, because that would be dandy ;D
Maybe force people to make short example missions on "desert island", and have them submit that?
Especially when you're using several .sqfs.
I want the function reference to be distinctly different from script snippets - it is a
reference for custom commands. I will put in a place to upload zips containing example missions
in addition to the single .sqf file.
_bodyang = [_guard,_deadguard] call loadfile "getang.sqf"
This defeats the purpose of having custom commands (functions) doesn't it? This is the same as:
GetAng = preprocessFile "getang.sqf"
_bodyang = [_guard,_deadguard] call GetAng
Except you could use the GetAng function multiple times. I think that all functions loaded to the function reference should have a name, and people should be encouraged to instantiate them via the preprocessFile command, rather than loadFile.
i want it automatic - i have som math functions dat i use function in function (based on each other ) so if i cantel dat it requires other 1s it wil b totaly kool
I will add it.
Just wanted to clear up that first thing. I know it is like a mini-script and loads faster. Just what exactly makes a funciton more usefull? Can you perform some script-controlled action quicker with a function?
OFP will work with functions (custom commands)
much, much faster than it works with scripts.
When you execute a script, it must be read from the hard disk (maybe), loaded into memory and interpreted by the OFP engine every time it is called.
When you preprocessFile a function (which is essentially a script written in a slightly different syntax) it will always be in memory, so the function acts as quicly as any other command.
So, if I made a function called GetPos2, that was similar to the command GetPos, my GetPos2 function would run at a speed similar to normal GetPos function.
If I made a script called GetPos2, when executed it would run much slower than the normal GetPos function.
When you are running a loop that executes a script on every unit in the game, for example, you are looking at a HUGE processor load. If you used preprocessed function (.sqf) files, the processor load is much, much smaller.
So, to summarise ->
- Use scripts (.sqs files) when you are doing something that only has to be done very few times in the mission (maybe monitoring and setting objectives for example).
- Use functions (preprocessed .sqf files) when you need to repeat a script more than once, the script is not as complicated (but note that a function can be as complicated as you like, and call other functions). An eject script, for example.
Scripts and functions are very similar - but they differ in terms of:
- Syntax (the scripting language used with functions is slightly different to normal scripts)
- Usage procedure (functions are preprocessed and then 'called' where as scripts are executed)
- Functions can return values
Many of the existing commands could be done better as functions - for example if you want a dude to get out of a jeep you'd have to use:
dude action["GETOUT",jeep]
unassignvehicle dude
you could make a function called 'GetDudeOut' by putting the following into a .sqf file:
(_this select 0) action["GETOUT",jeep];
unassignvehicle (_this select 0);
(_this select 0);
preprocess the file in init.sqs with:
GetDudeOut = preprocessfile "GetDudeOut.sqf"
then call the function wherever you want with:
[dude] call GetDudeOut
THE BEST THING ABOUT FUNCTIONS, THAT MAKE THEM TOTALLY DIFFERENT FROM SCRIPTS!Functions can
return values.
In a script, the only way you could return something is by using global variables.
However, using functions you can do this:
dudewhojustgotout = [dude] call GetDudeOut
::)
[url removed]func_test.zip]EXAMPLE MISSION[/url]