Search the Community
Showing results for tags 'macros'.
Found 2 results
-
macros introduce the project a3-lib-checks
bi_mg posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hello mission builders, scripters and developers, I like to introduce my project that is called a3-lib-checks on GitHub. I realy hope it useful for some of you. It is a kind of a BETA VERSION! Your tests in mission runtime envionment are very welcome 🙂. Link to Repository: https://github.com/DevMBeyer/a3-lib-checks Link to Unit tests: https://devmbeyer.github.io/a3-lib-checks/reports/index.html (supplement) TABLE OF CONTENT What these Libraries do The Usage of my libraries My Intension to write these libraries Why I used macro functions My research My conclusion Loops Conditions Lazy Evaluations Declarations Scopes Brackets Copy not everything How do I develop Unit Tests My Problems Test Cases Common Naming's Upload my Repository Website Entrypoint Bugs Feedback Apologizes CONTENT What these Libraries do This project contains several libraries with macro functions in it to enhanced data validation in Arma 3 scripts. The Macros are very system performance developed and should be easy to use. The functions in libraries are thematically and technically ordered. The aim of this project is to make data validation easier for other scripters and myself. Some Macros are a little confusing for you on how to work with them e.g. MB_IS_NIL( ARG ) which is nothing but isNil {ARG }. Nothing really useful but it has to be in the list of structure of macro functions for formality in my opinion. The Usage of libraries They are extremely useful for debugging a script or for conditions in mission runtime in my opinion. It should pull down the system performance in very little, so it is a good thing I guess. It depends on macro of course. My Intension to write these libraries While I was working on my SQF Scripts, I was often stuck with a bunch of errors. So I decided to developed a validation functions, which cost less system performance. As I said, it depends on the function of course. Why I used macro functions Macros must be imported from scripts, they can’t be present itself as script functions. But complex Macro functions are little faster as they are imported as code and not as a reference to the extern code. Later before the release, I will extract the string characters which are not functional like spaces between expressions. Therefor it runs little little little bit faster I hope. My research I tested with diag_performCode every single command or code construct I will work with, which is the fastest. My conclusion It is only my very personal conclusion below on the results of diag_performCode Loops I do not use for-, while- forEach-Loop. forEach loops brings more variables with them like _forEachIndex for example and decrease the system performance. In nearly all cases I don't need to use these variables, so findIf is the goal I found out. It only brings _x with it. It is really faster but it is really confusing because of the complexity. E.g. /* CODE */ \ private _copy = +ARR; \ ( ( _copy findIf { \ private _elem = ARR deleteAt 0; \ !( \ ( TYPES findIf { \ /* CONDITION */ \ } ) isEqualTo -1 \ ) \ } \ } ) isEqualTo -1 ) \ /* CODE */ \ Conditions The if-then-else should be slower than if-exitWith-expression. But both condition constructions do the same thing. // slower if ( CONDITION ) then { STATEMENT_1 } else { STATEMENT_2 }; // faster if ( CONDITION ) exitWith { STATEMENT_1 }; STATEMENT_2 Lazy Evaluations https://community.bistudio.com/wiki/Code_Optimisation#Lazy_evaluation The complex nested conditions are much faster than any other condition constructions like ifs, switch-cases. It depends on how to use them of course. false and true and true and true // slower false and { true and { true and { true } } } // faster Declarations I used as less declarations as possible and found out which the best performance is on declaration is – I guess. [] params [ [ "_foo", 0 ],[ "_bar", 0 ] ] // is little slower private _foo = 0; private _bar = 0; // is faster scopes The declaration private [ "_fnc" ]; _fnc = {}; is slowest as private _fnc = {} but if you declare this recursive function 10000 times, it is really useful and faster when you combine needed function scope to check n nested array as an argument. If the condition is matched in this function with the call 1000 times, the function just breaks out with the return and will not needto level up 1000 times to the first function call. But I am not sure of the results: private [ "_fnc" ]; scopeName "recursive"; _fnc = { /* CODE */ if( (CONDITION) call _fnc ) exitWith { true }; false breakout "recursive" }; ARG call _fnc; this function does not do anything but I hard coded to show what I means. Brackets I used brackets anywhere to enclose an expression like (_a+_b). The interpreter should like brackets, because he mustn’t search were the expression ends and prioritize which expression gets first. Again, it is my conclusion on the test results. ARR select 0 select 1 isEqualTo 0 // slower ( ( ( ARR select 0 ) select 1 ) isEqualTo 0 ) // faster Copy not everything I referenced not all Macro functions because they are sometimes dumplicates on commands in both functions so I must develop by foot e.g. MB_COMPARE_ARRAY_SIZE( ARR, 1 ) or { MB_COMPARE_ARRAY_SIZE( ARR, 2 ) } It is compact and more readable but both functions checks nil and array first, and that’s exaggerated. So I’ decided to solve this way on foot. !isNil{ARR} \ and { \ ( ARR isEqualType [] ) \ and { private _cnt = count ARR; \ (_cnt isEqualTo 1) \ or { _cnt isEqualTo 2 } \ } \ } \ I want only show what I mean. How do I develop I used my tag `MB` nearly everywhere in the code, therefore shouldn't be any name conflicts in the namespaces. I adopted BI Code Comments style in general with individualities I used K&R Code style My code should be well documented so far (if you leave out my grammar). Therefore the script comments should be understandable. Unit Tests I've written test cases and tested them with simple Unit Tests for every single macro function. Every Test Results from unit tests is generated as a report. You can see the reports of test results which were generated in html code. Unit test case arguments were changed, deleted, or expanded throughout the test by me. The reason: I have to correct individual test cases to show the differences in the individual test results. My Problems Test Cases I have optimized test cases and test arguments, while I tested each macro function to each test case. Meanwhile between past and now there are partly different and extended test arguments in unit test cases. It can be seen in the different unit test files and reports. I didn't write the test arguments to test the test arguments but to test the macro functions. So it is ok I think 👍. Common Naming's Partly it is very hard to choose the right name of each definition to show what the definition stands for regardless if function variables or constants. Upload my Repositorry I used Git of course for my project a3-lib-checks. when I started to upload there was an error occurred. Something with ssh I need to use and not TSL as the standard. So I Website Entrypoint I set the entrypoint of GitHub webpage. Nothing happes. I'm on to get thing done! Bugs As I said, the project is a BETA VERSION so there could bugs occurs, regardless of units tests! I’m just one person in the Project! Please email me or contact me in this thread or write a PN to me in this platform if there is any bug displayed with my macros if you include correctly of course 😉. Feedback Feedback is very welcome 🙂. It is useful for me to get feedback on my macros and my project. You can Criticism me, regardless if positive or negative. Every feedback is useful if the feedback is objective. Apologizes English is not my mother tongue. I hope, it can be understandable if someone reads my scrip comments I am just a Developer with amateur experience on Arma coding. I'm a greenhorn in https://github.com/. It is completely new to me. So I hope everything is clear by now 😬🙄 . Enjoy Coding 😊 Best regards MB -
[SOLVED]Partial subclass inheritance issue
Grester posted a topic in ARMA 3 - ADDONS - CONFIGS & SCRIPTING
Without going to much off topic I'll give a bit of background on why such question... I'm working on a clothes mod that creates new uniforms, helmets,etc. The scripts weren't much optimized and were pretty much copy+paste based. Worked but if I wanted to change a value of a type of vest then I had to change them all. So I started adapting the scripts to be based on inheritance so that all I had to change for the childs were textures. However I started to face some issues of many values not being inherited, particularly stats of uniforms which could be perhaps answered with the fact that some stats are present in subclasses which weren't declared in the children. However my vests children don't have subclasses declared and have the correct stats so I'm not sure. As I was doing some research looking for answers I've stumbled upon Macros which seems to be a replacement for my inheritance based system since it just copycats the parent and all I have to do is input the values into the parameters. Thus my question, which should have I used in the first place? May have I miswritten the inheritances? Or perhaps a mix of both? I haven't fixed the problem yet as I was looking for an answer on the best aproach towards the problem. It seems that backpacks, vests and helmets are working correctly but I'm not entirely sure since uniforms stats and some subclasses variables are missing/generating errors. This also brings me doubts wether or not Units are correcly setup despite at first glance they seem to have inherited correctly. Below I'll leave an example of my classes. (For the sake of simplicity for now I'll just take a segment from my vests. If it's due necessary later on I could post segments from the Units/Uniforms files.) //Also authors don't seem to inherit properly. (...) class cfgWeapons { class VestItem; class Vest_Camo_Base: ItemCore { class ItemInfo; }; #include "cfgVest.hpp" }; (...) class VEST_TAC_Desert: Vest_Camo_Base { author = "Example"; //vehicleClass = myVest; side = TWest; scope = 2; displayName = "TacticalVest Desert"; picture = "\A3\characters_f\Data\UI\icon_v_tacvest_blk_ca.paa"; model = "A3\Characters_F\Common\equip_tacticalvest.p3d"; hiddenSelections[] = {"Camo"}; hiddenSelectionsMaterials[] = {"A3\Characters_F\Common\Data\tacticalvest.rvmat"}; hiddenSelectionsTextures[] = {"forces\tex\vest\deserttactical.paa"}; class ItemInfo: VestItem { class HitpointsProtectionInfo { class Chest { HitpointName = "HitChest"; armor = 8; PassThrough = 0.3; }; class Diaphragm { HitpointName = "HitDiaphragm"; armor = 8; PassThrough = 0.3; }; class Abdomen { hitpointName = "HitAbdomen"; armor = 8; passThrough = 0.3; }; class Body { hitpointName = "HitBody"; passThrough = 0.3; }; }; uniformModel = "A3\Characters_F\Common\equip_tacticalvest.p3d"; containerClass = "Supply120"; mass = 80; hiddenSelections[] = {"camo"}; }; }; class VEST_TAC_WoodlandA: VEST_TAC_Desert { author = "Example"; displayName = "TacticalVest Woodland-A"; hiddenSelectionsTextures[] = {"forces\tex\vest\woodlandtactical.paa"}; };- 4 replies
-
- Macros
- Inheritance
-
(and 3 more)
Tagged with: