Well it might be a surprise to some, but I've never really learnt to use CBA functionality in my coding.
I use the odd function but never got into use the shortcut macros, etc. Recently, Sickboy enabling Function Caching, which provides significant performance improvements to large projects - like MSO. So I've finally pulled my finger out and started to look at using it.
In doing so, I will try to document what I learn here, for all to learn from.
Welcome to AUSARMA - The Dedicated Australian & New Zealand Arma Community
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and much more. If you already have an account, login here - otherwise create an account for free today!
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and much more. If you already have an account, login here - otherwise create an account for free today!
#1
Posted 01 October 2011 - 11:48 PM
#2
Posted 02 October 2011 - 12:18 AM
Ok, first thing to learn is this function caching stuff.
So normally, you "create" a function using something like this:
There is a preferred method of creating functions using the BIS Functions module (see here - http://community.bis...g_new_functions). These are automatically cached by CBA, which covers most of my functions anyway.
But for the odd function like the above, here is the replacement code:
This would utilise the CBA Function Caching and optimise performance.
So normally, you "create" a function using something like this:
fn_Client_SyncHQState = compile preprocessFileLineNumbers "support\modules\WHB_FOBspawn\common\fn_Client_SyncHQState.sqf";
There is a preferred method of creating functions using the BIS Functions module (see here - http://community.bis...g_new_functions). These are automatically cached by CBA, which covers most of my functions anyway.
But for the odd function like the above, here is the replacement code:
#include "\x\cba\addons\main\script_macros_mission.hpp" fn_Client_SyncHQState = COMPILE_FILE2(support\modules\WHB_FOBspawn\common\fn_Client_SyncHQState.sqf);
This would utilise the CBA Function Caching and optimise performance.
#3
Posted 02 October 2011 - 12:43 AM
Next most useful CBA Macro would have to be PARAMS.
Normally, you would do something like this:
With CBA, you can shorten it to this:
Also PARAMS_1 supports both: [_firstParam] and _firstParam call function, so you dont HAVE to use an array as parameter for PARAMS_1.
See here for more info - http://dev-heaven.ne...p.html#PARAMS_n
If _specs was optional (and the default value being an empty string (""), you could do the following:
See here for more info - http://dev-heaven.ne...l#DEFAULT_PARAM
Note: Make sure there are no spaces between parameters.
Normally, you would do something like this:
private ["_target", "_specs"]; _target = _this select 0; _specs = _this select 1;
With CBA, you can shorten it to this:
#include "\x\cba\addons\main\script_macros_mission.hpp" PARAMS_2(_target,_specs);
Also PARAMS_1 supports both: [_firstParam] and _firstParam call function, so you dont HAVE to use an array as parameter for PARAMS_1.
See here for more info - http://dev-heaven.ne...p.html#PARAMS_n
If _specs was optional (and the default value being an empty string (""), you could do the following:
#include "\x\cba\addons\main\script_macros_mission.hpp" PARAMS_1(_target); DEFAULT_PARAM(1,_specs,"");
See here for more info - http://dev-heaven.ne...l#DEFAULT_PARAM
Note: Make sure there are no spaces between parameters.
#4
Posted 02 October 2011 - 05:42 AM
A word of advice here on macros:
Many very experienced and intelligent coders say code readability is among if not the most important goal.
Macros often and easily make code a lot harder to understand.
For example without knowledge about the macro, you have to assume from the name, which is often badly chosen, what it might do.
What is the real way to go:
1. Don't be lazy. To save a few keyboard pushes isn't worth it.
2. Make use of and support IDEs that provide code completion and code templates.
Many very experienced and intelligent coders say code readability is among if not the most important goal.
Macros often and easily make code a lot harder to understand.
For example without knowledge about the macro, you have to assume from the name, which is often badly chosen, what it might do.
What is the real way to go:
1. Don't be lazy. To save a few keyboard pushes isn't worth it.
2. Make use of and support IDEs that provide code completion and code templates.
#5
Posted 02 October 2011 - 08:38 AM
kju, can you link us to these IDEs you're referring too?
I disagree with your statement though - once you know what the macro is for, its a lot less effort to use and read it. Yes I agree, its difficult for someone who has never used those particular macros before which is why I have taken this long to start using them, but if I had a cheat sheet like this thread - I would have adopted them a lot sooner.
I disagree with your statement though - once you know what the macro is for, its a lot less effort to use and read it. Yes I agree, its difficult for someone who has never used those particular macros before which is why I have taken this long to start using them, but if I had a cheat sheet like this thread - I would have adopted them a lot sooner.
#6
Posted 02 October 2011 - 02:20 PM
Good thread Wolffy, interesting to see what you come up with!
I recently got reminded using a trigger condition such as:
and an On Act such as:
the text will only be returned to the player activating the trigger, not all players.
Aside from using a hint (which I think is global), someone somewhere in a thread about MP messages suggested that CBA had some built in function to handle MP messages better? have you uncovered anything in your travels on this?
Edit: whilst writing this, dug up this, but must admit, not really sure what I need to do to make the above TitleText global from within a trigger:
http://dev-heaven.ne...m_Events_System
I recently got reminded using a trigger condition such as:
Quote
player distance briefcase <=2
and an On Act such as:
Quote
titleText [""A female civilian has been found."",""PLAIN DOWN""];
the text will only be returned to the player activating the trigger, not all players.
Aside from using a hint (which I think is global), someone somewhere in a thread about MP messages suggested that CBA had some built in function to handle MP messages better? have you uncovered anything in your travels on this?
Edit: whilst writing this, dug up this, but must admit, not really sure what I need to do to make the above TitleText global from within a trigger:
http://dev-heaven.ne...m_Events_System
#7
Posted 02 October 2011 - 03:10 PM
skufer and sqfeditor are the two most recent
How is it less effort to read? To save typing, the macros are giving awkward, cut names.
In addition they hide what is being done. Normally you use functions to be able to step through code
from bottom to the top.
One perfect example of a key issue.
I am curious wolffy - do you code for a living and if so did you study software engineer and read books of experienced people?
How is it less effort to read? To save typing, the macros are giving awkward, cut names.
In addition they hide what is being done. Normally you use functions to be able to step through code
from bottom to the top.
Quote
its difficult for someone who has never used those particular macros before
One perfect example of a key issue.
I am curious wolffy - do you code for a living and if so did you study software engineer and read books of experienced people?
#8
Posted 05 October 2011 - 12:17 PM
-ZSU- Gnarly, on 02 October 2011 - 02:20 PM, said:
Aside from using a hint (which I think is global), someone somewhere in a thread about MP messages suggested that CBA had some built in function to handle MP messages better? have you uncovered anything in your travels on this?
kju, I'm not going to debate the pros and cons fo MACROs with you - you have your opinion and a herd of wild horses won't sway you from it.
Not sure what you're trying to achieve asking me about my experiences with software engineering - no matter how I answer that question, it can only end in further argument.
Your points have been raised and acknowledged, now let me get back to displaying examples.



Sign In
Create Account


Back to top

