sarogahtyp 1101 Posted April 21, 2016 Hey guys, usualy I write a function put it in an example.sqf and then I do this: fnc_example = compileFinal preprocessFile "example.sqf"; now I have a file with a bunch of functions in the file example_fncs.sqf like this: fnc_example_a = { }; fnc_example_b = { }; fnc_example_c = { }; how can I preprocess the file and precompile that functions for the later use with call and spawn? Share this post Link to post Share on other sites
Grumpy Old Man 3535 Posted April 21, 2016 Why not set up your own functions library? Cheers 2 Share this post Link to post Share on other sites
jshock 512 Posted April 21, 2016 https://community.bistudio.com/wiki/Function#Inline_functions 1 Share this post Link to post Share on other sites
Greenfist 1861 Posted April 21, 2016 Simply: call compileFinal preprocessFile "example_fncs.sqf"; 1 Share this post Link to post Share on other sites
sarogahtyp 1101 Posted April 21, 2016 I knew that this should be easy but I didnt get howto do it. thx alot guys... Share this post Link to post Share on other sites
celludriel 79 Posted April 21, 2016 I have to agree with setting up your own function library. We are 2016 now, the CfgFunction is the new way to go. for example class MyFunctions{ tag = "MYFNC"; class MyFunctionsInitialize { file = "functions"; class getUnitCount {}; }; }; Then put your functions in seperate sqf files in the folder functions with fn_ in front of them fe: fn_getUnitCount.sqf You can then call them _count = [] call MYFNC_fnc_getUnitCount; experiment with it you will not regret it ! 2 Share this post Link to post Share on other sites
gc8 968 Posted April 21, 2016 if you just call the execVM on the file where your functions are the file will be preprocessed. You dont need to do anything else. The result as far as I know should be same in both methods when calling those function. 1 Share this post Link to post Share on other sites
sarogahtyp 1101 Posted April 21, 2016 (edited) Why not set up your own functions library? Cheers hmm ... idk. could u explain that a bit more pls? I have to agree with setting up your own function library. We are 2016 now, the CfgFunction is the new way to go. for example class MyFunctions{ tag = "MYFNC"; class MyFunctionsInitialize { file = "functions"; class getUnitCount {}; }; }; Then put your functions in seperate sqf files in the folder functions with fn_ in front of them fe: fn_getUnitCount.sqf You can then call them _count = [] call MYFNC_fnc_getUnitCount; experiment with it you will not regret it ! I ll try that. thx alot Edited April 21, 2016 by sarogahtyp 1 Share this post Link to post Share on other sites
jshock 512 Posted April 21, 2016 hmm ... idk. could u explain that a bit more pls?My link, part on "functions as files" or "file functions" or this:https://community.bistudio.com/wiki/Functions_Library_(Arma_3) 1 Share this post Link to post Share on other sites
sarogahtyp 1101 Posted April 21, 2016 (edited) My link, part on "functions as files" or "file functions" or this: https://community.bistudio.com/wiki/Functions_Library_(Arma_3) Link is not working this one is :-): https://community.bistudio.com/wiki/Functions_Library_(Arma_3) Edited April 21, 2016 by sarogahtyp Share this post Link to post Share on other sites
jshock 512 Posted April 21, 2016 Link is not workingWell then....https://community.bistudio.com/wiki/Functions_Library_(Arma_3) EDIT the stupid auto url tags are getting screwy with the ')' so here: https://community.bistudio.com/wiki/Functions_Library_(Arma_3)#Finding_a_Function 1 Share this post Link to post Share on other sites
Arkensor 96 Posted April 21, 2016 Well then.... https://community.bistudio.com/wiki/Functions_Library_(Arma_3) Well then ... Let me fix that for you ;) https://community.bistudio.com/wiki/Functions_Library_(Arma_3) 1 Share this post Link to post Share on other sites
jshock 512 Posted April 21, 2016 Well then ... Let me fix that for you ;) https://community.bistudio.com/wiki/Functions_Library_(Arma_3) Yea thanks, on my phone, hard to defeat an oppenent such as an auto url tag that emplaces itself prior to a parenthesis... 1 Share this post Link to post Share on other sites
sarogahtyp 1101 Posted April 22, 2016 okay, I read that wiki entry about the function library and yes of course i ll use it. maybe i didnt get all of that wiki entry because some questions remain. If I understood that correct then I ve to write every function in its own sqf file if I use that library or is it possible to do one file with a few functions with it? Next question. Is there a way to force server sided functions to be compiled at server only? Share this post Link to post Share on other sites
jshock 512 Posted April 22, 2016 The point of the library is to have, one function, one file, in theory, sure you could put more than one function per file and precompile/postInit them, but it takes away from the intent of the library (at least in my opionion). For server side stuff, you could either make a server side addon, or just make sure at the top of your server functions to have a check, if the accessing machine isn't the server, exit the function. 1 Share this post Link to post Share on other sites
sarogahtyp 1101 Posted April 22, 2016 The point of the library is to have, one function, one file, in theory, sure you could put more than one function per file and precompile/postInit them, but it takes away from the intent of the library (at least in my opionion). For server side stuff, you could either make a server side addon, or just make sure at the top of your server functions to have a check, if the accessing machine isn't the server, exit the function. thx for that info. seems to be the time to learn how to create addons... Share this post Link to post Share on other sites
jshock 512 Posted April 22, 2016 thx for that info. seems to be the time to learn how to create addons... Easier than you may think, you basically just add a config.cpp file (essentially similar to the description.ext) declare your functions there (in addition to CfgPatches) and then all the other necessary function files, use A3 Tools to pack it, done :). 1 Share this post Link to post Share on other sites
celludriel 79 Posted April 22, 2016 Take a look at https://github.com/Celludriel/dyncap It's a small lib I created a while back and updated a few days ago. There is a perfect example on using CfgFunctions. You really don't want one file with a bunch of functions, each function is just it's own file. A lot has to do with code cleanliness Share this post Link to post Share on other sites
sarogahtyp 1101 Posted April 22, 2016 Okay, as I said I ll use that libráry in future but I ve some thoughts I d like to throw. that library has surly advantages but I see some disadvantages. If I d like to release a script then I want to release it as easy as possible for the mission designer who will use it. I dont like that the functions must be defined in description.ext. A mission designer who wants to use the functions has to merge my description.ext with its own. As some guys r only modifying existing missions to implement some more features and then run it on their server they dont have much knowledge about description.ext. They just want to have a command to init the script and then use the features of it via functions. The necessity of those description.ext entry forces me as the creator of a script to provide two ways for implementation of my scripts in missions now. The easy way with the classic initing and precompiling and for the mission designers who r familiar with description.ext the way with that function library. It would be easier if there were a way to implement the functions in the library by just including a custom file in discription.ext by doing somethinge like #include "custom.ext"... Share this post Link to post Share on other sites
Fiddi 68 Posted April 22, 2016 You can do that, I have this in my description.ext for example: class CfgFunctions { #include "SideOps\CfgFunctions.hpp" }; And the CfgFunctions.hpp: class FRED { tag = "FRED"; class sideOps { file = "SideOps\Functions"; class endSideGraphic {}; class infoText {}; class selectMission {}; class squadPatrol {}; class strategicMapOpen {}; class taskPatrol {}; class teamPatrol {}; class typeText {}; class vehiclePatrol {}; }; class missionTypes { file = "SideOps\MissionTypes"; class Case0Rescue {}; class Case1Steal {}; class Case2Target {}; class Case3Destroy {}; class Case4Pilot {}; class Case5Sabotage {}; class Case6Transport {}; class Case7Convoy {}; }; }; Works perfectly and it even shows up in the ingame functions viewer. 2 Share this post Link to post Share on other sites
sarogahtyp 1101 Posted April 22, 2016 okay that is a good thing, but not perfect. the mission designer has to implement it at the correct position. it would be better if he could just write the include at top of description.ext. but thanks for ur hint that its generally possible to do so. Share this post Link to post Share on other sites
jshock 512 Posted April 22, 2016 Not to be a complete ass, but honestly most decent mission makers can probably figure out what to do with it given a proper example as many scripters have given for their code (look at all my code pages), it's not complete rocket science, and if a mission maker truely wants the feature you provide I'm sure they will take the time to find out how to implement it. 3 Share this post Link to post Share on other sites