Jump to content
Sign in to follow this  
Coyota

Using call as a shortcut

Recommended Posts

I have been cleaning and compressing one of my scripts shorter.

Call seemed like handy way to shave off big bunch of lines from the script.

Script is working just fine but im wondering if theres any point using call like this.

_wpset = {
_this setWaypointBehaviour "AWARE";
_this setWaypointCombatMode "RED";
_this setWaypointSpeed "NORMAL";
_this setWaypointCompletionRadius 20;
_this setWaypointStatements  ["true",""];
};

_crgwp1 = _group addWaypoint [_startwp, 0];
_crgwp1 setWaypointType "MOVE";
_cgrwp1 call _wpset;

I mean is it worth it?

Let's say i cut script way shorter with this.

Does the use of call actually make it worse compared to just having all the lines?

Is it just matter of personal preference?

Or is it even nono to use call like this?

These might be "stupid questions" but curiosity got me here.

Share this post


Link to post
Share on other sites

No harm done doing it like that, I do it as well. It's very nice when you have to run same code more than once.

Share this post


Link to post
Share on other sites

You've just discovered functions - generally a good thing. In fact, if you give _wpset a global name like "Coyota_wpset" you can even call if from other scripts. :)

Share this post


Link to post
Share on other sites

I put lot of similar functions in one file, or use it to "package" a script so it's easier to use without having to put to use.

Share this post


Link to post
Share on other sites

When using a "package" of functions like you said above, it would be more professional to also describe them in description.ext (cfgFunctions).

But I also found call command useful while converting sqs scripts to sqf. When I wanted to convert goto loops and it was important to operate in one script and use only normal loops and no recursion.

Edited by RazorX

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  

×