Jump to content
Sign in to follow this  
dwringer

Assorted Scripts w/map, reduce, filter, shuffle, range, sorted, alist...

Recommended Posts

Hello,
If anyone would like to see a wide assortment of scripts including some helpful functional programming tools and array manipulation utilities, I have assembled several modules with extremely basic documentation at https://github.com/dwringer/a3system

You are pretty much on your own with these, especially some of the less documented stuff, but the stuff in "lambda" and "vectools" is pretty well tested so far and helpful in a lot of situations.

I would be interested to hear if anyone makes any use of some of this.

Best of luck, and let me know if there are any usage questions or problems identified.

 

EDIT 2: There is now a class system included that is superficially similar to Python classes.  These can be defined in header files using syntax macros, or created on-the-fly using the right functions.  So far there is an ObjectRoot and Dictionary class, but these are more examples than anything.

EDIT:

Fixed a couple of functions - in particular, fnc_sorted was destroying the original array passed to it. There was also a problem with using negative indexing in fnc_subseq which should be fixed now.

Share this post


Link to post
Share on other sites

I am probably going to work some parts of this into their own independent modules (they can already be used that way but perhaps the codebase isn't too approachable). But, I wanted to announce a couple of things here:

If anyone checked out this code after my first post you may have found some show stopping bugs. I have been working extensively on this and everything should be working as intended as of now.

Most importantly: dynamic classes!
I've seen a few other class implementations in sqf out there, but none of them were much like this - although I'm sure it is out there somewhere :).  I urge you all to check out the idea and share what you think. Here's an example class definition file to hack into objects' native dictionary capabilities:
https://github.com/dwringer/a3system/blob/master/classdef/Dictionary.hpp

Share this post


Link to post
Share on other sites
Guest

I am probably going to work some parts of this into their own independent modules (they can already be used that way but perhaps the codebase isn't too approachable. But, I wanted to announce a couple of things here:

If anyone checked out this code after my first post you may have found some show stopping bugs. I have been working extensively on this and everything should be working as intended as of now.

Most importantly: dynamic classes!

I've seen a few other class implementations in sqf out there, but none of them were much like this - although I'm sure it is out there somewhere :). [EDIT: Actually, I do remember a forest-fire-fighting mod for Take On Helicopters that had a system somewhat in this direction.] I urge you all to check out the idea and share what you think. Here's an example class definition file to hack into objects' native dictionary capabilities:

https://github.com/dwringer/a3system/blob/master/classdef/Dictionary.hpp

 

We need a proper implementation from Bohemia imo.

Share this post


Link to post
Share on other sites

We need a proper implementation from Bohemia imo.

I have always wondered why they didn't add these features to SQF, and presumed it is because if they are used excessively it can be grossly inefficient.  I remember hearing that they were looking into Java or something, but that somehow doesn't sound very appealing.  

 

I haven't implemented any complex systems with these classes yet, but the functional tools are already proving their worth in my missions and experiments.  The class system will surely prove invaluable (and has already been helpful) in organizing mission components, inheritance trees among abstract concepts, etc.

 

Anyway, just wanted to let everyone know I have massively upgraded the documentations (trying to find errors - especially in the dependency listings - is something I don't find to be a very rewarding use of time).  They should be usable, which is all that I want from them, but if you have trouble getting a module to work from the docs just try adding the whole repo to your mission first.  That way you can make sure to have any unlisted dependencies.

 

The class system has been tested and proven effective with the ObjectRoot and Dictionary classes, which show off the abstraction and inheritance capabilities avaialble.  Some other test/example classes of low quality are also included (these are in the classdef/ folder).

Share this post


Link to post
Share on other sites

Interesting.

 

...however, I can't help but wonder why you don't make use of the functions library there:

https://community.bistudio.com/wiki/Functions_Library_(Arma_3)

I'm afraid I don't fully understand the reference, although looking through the functions I have found a couple that would have made string manipulation slightly simpler and probably more efficient.  I must caution that this system is not designed for speed, but simply for power of abstraction.  The chaining of functions can get very deep and is bound to cause problems if abused or used heavily. 

 

I noted that there is a way to register functions in the game's function library, which I have not done as it is all new to me (I have not been active in the community for a while).  I welcome any specific suggestions on how to handle improvements and optimizations like that, but I am out-of-touch when it comes to standard practices with sqf.  This is also designed and tested only for single-player; if anyone with multiplayer coding experience has advice or concerns I'd be grateful.  I'm not entirely sure how the scripts would interact in such an environment.

 

Finally, I have added to the class hierarchy including a unit group abstraction that offers a center_pos method (giving the mean position of all units in the group instance).  I will be continuing to work on fleshing out classes but the things in the repository are bound to fluctuate wildly in quality as I continue updating and moving things around.

 

[Edited for clarity]

 

If you are wondering why fnc_sorted would be more useful than the BI sort functions, it is because you can use fnc_lambda inline to create a custom comparison function and pass it , and an array of any supporting variables, to the sort and get any ordering you can define.

 

In any case, I have just finished a couple of methods on a CrewUnitGroup class.  This class keeps unit arrays for various roles (driver, gunner, cargo), and vehicles themselves.  There is a simple "assign" method (remove has not been properly overloaded yet so that functionality is not present) which takes a unit and role and adds it to the corresponding array.  The other method is "board_instant", which loops through vehicles dynamically assigning drivers and gunners, then filling in cargo as space allows.  Hopefully this is a better example of what is possible, and maybe even conceivably useful.

 

[Edited again for update]

Share this post


Link to post
Share on other sites

did you consider to contribute these to CBA or join the project altogether?

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  

×