Jump to content
Sign in to follow this  
Horner

Extended Functions Library

Recommended Posts

Extended Functions Library



by Horner

I created this library to help out scripters with common (or not so common) tasks that they don't want to code. This library contains functions ranging from global execution functions to various string altering functions. This library is nowhere near completed, and I will be updating this fairly regularly. If you want to help contribute to the library, either post a reply on this thread or PM me with the code and I can go ahead and add your code into it. I will also be taking requests for functions that you feel would be helpful to your mission-making/scripting. So if you have a suggestion you can either post it here or PM me. At the moment this library only consists of some code I've put together and some other code that I've had lying around so if you're not impressed by the first release of this, then just remember there's a lot more to come. I hope you all will find this project useful and any feedback is appreciated. Proper documentation and use of each function is located within ext > ext_fnc_lib.sqf. Each function has information on it's use, parameter explanation, and other documentation.

Keep in mind this project is by a scripter for other scripters, therefore I need your guys' input/suggestions to make this the best I can! Also, if you have an issue with any of your content being included into the Library just pm me and I will remove it, or if I have forgot your name in the credits for something you have made then pm me and I'll include it.

Download

https://dl.dropbox.com/u/67505055/ext.zip

- Feel free to mirror

How To

1. Download the link provided above

2. Extract to your mission folder

3. Put this line of code into your init.sqf

call compile preProcessFile "ext\ext_fnc_init.sqf";

Contributors

- Horner

- marker

- Muzzleflash

Dev-Heaven

https://dev-heaven.net/projects/ext-fnc-lib

Edited by Horner
Added DH Page

Share this post


Link to post
Share on other sites

Sounds great. Thanks for your hard work definitely will be looking at this.

Share this post


Link to post
Share on other sites

Updated to v1.01

- Added: ext_fnc_listHint

- Added: ext_fnc_globalMessage

- Added: ext_fnc_reverseString

Share this post


Link to post
Share on other sites

Updated to v1.02

- Added: ext_fnc_findMissionSpot

- Added: ext_fnc_addCommas

Share this post


Link to post
Share on other sites

You should do all of these small updates, and when you get a fairly large library, make a PDF. Rinse repeat.

Share this post


Link to post
Share on other sites

Good idea. I'm awared about few interesting function libraries released by some people (Rube, CBA, Kronzky...), but there is lack of any "central library", one place, where can be found all of them. If I can suggest something - when library will become big enough, good idea may be to divide functions for several files by their theme (category as: math, MP, strings, objects, complex etc). Also perhaps can be added full content, alphabetical and category index file with pointed sqf file and perhaps even exact line within it for each function.

And here is prepared my contribution. Contains collected together, not sorted, chosen from my several projects functions, that are universal enough to be useful also apart of these projects. Included are and marked two sets of functions, that work together, but also number of quite simple functions. Three of them (also marked) contain code inspired by other people work. Tried to keep description format, but language errors are possible. Mostly tested, but for a few added here untested changes (all passed Squint check though):

RYD_functions.sqf

Share this post


Link to post
Share on other sites

Yeah. It would be cool to divide those categories like you suggested and make them as pdf library. That would be awesome. :cool:

Share this post


Link to post
Share on other sites

I think I'm going to stick to just an SQF library tbh, but I can sort them into categories, these were the ones I was thinking.

- Mathematical

- Strings

- MP

- Misc

If anyone has any other category ideas let me know, just trying to keep this as clean as possible.

Share this post


Link to post
Share on other sites

Updated to v1.03

- Added: lib folder

- Changed: Moved lib files to the lib folder

- Changed: Seperated functions into categories

Share this post


Link to post
Share on other sites

I'm in the process of adding in some of rydygier's functions but I need some more suggestions, as I'm running out of ideas.

Share this post


Link to post
Share on other sites

heres two i find i use a little.

/*
  Description:
   copies object inventory to clipboard and displays a hint

  Parameter(s):
   _this select 0: (Object)

*/


private ["_in","_strVal","_wep","_mag","_object"];

_object = _this select 0;


if (_object isKindOf "CAManBase") then
{
_in = [_object] call BIS_fnc_invString;

_strVal = format ["%1", _in];

hint _strVal;

copyToClipboard _strVal;

}else{
_wep = getWeaponCargo _object;
_mag = getMagazineCargo _object;

_strVal = format ["WEAPONS:::: \n %1 \nMAGAZINES:::: \n %2", _wep,_mag];

hint _strVal;

copyToClipboard _strVal;
};

/*

  Description:
   copies object type to clipboard and displays a hint

  Parameter(s):
   _this select 0: (Object)

*/

private ["_strVal","_object","_objectType"];

_object = _this select 0;

_objectType = typeOf _object;

_strVal = format ["%1", _objectType];

hint _strVal;

copyToClipboard _strVal;

Share this post


Link to post
Share on other sites
I'm in the process of adding in some of rydygier's functions but I need some more suggestions, as I'm running out of ideas.

What about functions that takes other functions as parameter? Allows you to generalize some functions:

ext_fnc_filter = {
   private ["_array", "_predicate"];
   _array = _this select 0;
   _predicate = _this select 1;
   _newArray = [];
   {
       if (_x call _predicate) then {_newArray set [count _newArray, _x];};
   } forEach _array;
   //Return a new array containing only those elements that passed the test.
   _newArray
};

What can you use it for? Anywhere you need to only keep the elements in the array that fulfils some criterea. Now you only need to specify the criterea:

//Check if a object is an APC.
_checkAPC = {
   (_this isKindOf "Tank" || _this isKindOf "Car") && 
   (getNumber (configFile >> "cfgVehicles" >> (typeOf _this) >> "transportSoldier") >= 4)
};

//Now get all those APC's only
_myNewApcArray = [myBunchOfUnits, _checkAPC] call ext_fnc_filter;

//Further filter. Only keep those which have driver that are blufor:
_readyAPCs = [_myNewApcArray, {
  private ["_driver"];
  _driver = driver _this;
  (!isNull _driver) and {side _driver == west}
}] call ext_fnc_filter;

That way you don't have to keep rewriting filter code, only the changing criterea. Just remember to document that you have to 'private' all the local variables the criterea function uses, otherwise it can cause issues.

Edited by Muzzleflash

Share this post


Link to post
Share on other sites

Here's a count down timer I made. Not sure if it's the kinds of things you guys are looking for here.

TimerDone=False

FOB_TIMER_FNC = 

{



           Private ["_Seconds","_Minutes"];

           _Seconds = 60;
           _Minutes = _This Select 0;

           While {!TimerDone} Do 

             {
                  _Seconds = _Seconds -1;
                  If ((_Seconds == 0) && (_Minutes > 0)) Then 

                    {
                        Hint Format ["%1:0%2",_Minutes, _Seconds];
                        sleep 1;
                       _Minutes = _Minutes - 1;
                       _Seconds = 59;

                    };

                        If (_Seconds >= 10) Then { Hint Format ["%1:%2",_Minutes, _Seconds] } Else { Hint Format ["%1:0%2",_Minutes, _Seconds] };

                            If ((_Minutes == 0) && (_Seconds < 1)) ExitWith 

                                     {

                                        TimerDone=True; 
                                        Hint "The timer has expired";
                                        Sleep 2;
                                        Hint "";

                                     };

                                                         Sleep 1;


            };







};

[4] Spawn FOB_TIMER_FNC;                  


Share this post


Link to post
Share on other sites

what about -MP sidew, sideE, & Group chat, Global hint? have them here if you want them - save typing?

Share this post


Link to post
Share on other sites

Global Hint, Global GroupChat etc can be used with globalCall and globalSpawn.

urgh, I wish mrCurry would have included a syntax example of his function, anyone know what the args look like?

---------- Post added at 01:07 PM ---------- Previous post was at 12:10 PM ----------

Updated to v1.04

- Added: ext_misc_fnc_filter

- Added: ext_str_fnc_capitalize

- Added: ext_str_fnc_strToArr

- Added: ext_str_fnc_capsLeft

- Added: Array Library

- Added: ext_arr_fnc_pullIndex

- Added: ext_arr_fnc_selectRandom

Share this post


Link to post
Share on other sites

urgh, I wish mrCurry would have included a syntax example of his function, anyone know what the args look like?

It's in the function:

Simple use:  		building call c_fnc_getBuildingPositions
Parameter(s): 		building - Object
Returns: 			All positions in a building

Advanced use:		[building (, offset)] call c_fnc_getBuildingPositions
Parameter(s): 		[
			building - Object ,
			offset -(optional) Number - offset height which balcony-positions are measured against - default: 1.5
		]

Share this post


Link to post
Share on other sites

Hey Horner I think it would be a good idea to have a very simple working demo of each function on the list. Just my two cents. I feel the same way about the current scripting command wiki page.

Share this post


Link to post
Share on other sites

I've just opened a dev-heaven page, if you would like to use it for feature requests, bug reports, etc. I'll be keeping updated on this thread along with the DH page.

Share this post


Link to post
Share on other sites

Updated to v1.05

- Added: ext_math_fnc_buildIntArray

- Added: ext_math_fnc_getDecimals

- Added: ext_str_fnc_capsSelect

- Added: ext_str_fnc_removeChars

- Changed: Method behind ext_math_fnc_addCommas

Share this post


Link to post
Share on other sites

Just realized I broke ext_math_fnc_addCommas, I'll fix it soon.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×