Jump to content
Sign in to follow this  
zonekiller

Lets Hear Your Thoughts

Recommended Posts

welcome.gif

Hi Guys And Gals

Allot of work goes into some of the beta scripts

and it would be good to hear you ideas about the beta scripts.

and also tips on improving the code as most of us are

not experts but enjoy the learning curve.

and whether you like the script or mission or not

and whether you might find it useful in missions ect

We all like sharing our scripts so how about sharing your thoughts

Im don’t wish to come across like im putting pressure on anyone

Its just we would like to hear your thoughts and ideas.

Thanks Michael

Share this post


Link to post
Share on other sites

He just may be a person wanting to learn...Just a guess, from the looks of it...

Im not a scripting guru...but..

My thoughts are this:

keep asking questions (never be arrogant...), don't get discouraged when things seem to complex,use the wiki and always remember to help people out on the forums if you can..if you know an answer to a posted question...don't be an ass and ignore it...(I think we all have asked questions and we must all start somewhere)...

Regards,

Iceman

Share this post


Link to post
Share on other sites

Hmm..something went a bit wrong in this post.

Share this post


Link to post
Share on other sites
Quote[/b] ]and also tips on improving the code as most of us are

not experts but enjoy the learning curve.

That’s a tough question, which might explain why you've only had one real reply. Each script can vary depending on the situation. Whats efficient practice for one script, may not be the same for another script.

Then take the way Arma works in general. One of the traditional concerns in programming was removing duplicate code. If you use the same chunk of code, multiple times, you should really move the code into a global function. That way your scripts become smaller and are easier to maintain. But because of the save game limitations, having to many global functions (i.e variables) can cause problems later on. The same applies to the spawn command, you can pre-compile scripts at the start of the mission to avoid loading them in game. But again this will eat up the space allocated in save game files.

Arma's scripts run pretty fast considering. In many cases there is just no need to worry about such things. A lot of stuff I do is done purely out of habit or preference. Take commands like Sin & Cos, in the old days they could eat up a big chunk of the processing cycle, for example:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">WaitUntil

       {

       _Pos=GetPos _ParentObj;

       _X=_Pos Select 0;

       _Y=_Pos Select 1;

       _Dir=GetDir _ParentObj;

       _SinX=Sin _Dir;

       _CosY=Cos _Dir;

       _PosX=_X+(_SinX*100);

       _PosY=_Y+(_CosY*100);

       _Obj01 SetPos [_PosX,_POsY];

       _PosX=_X+(_SinX*120);

       _PosY=_Y+(_CosY*120);

       _Obj02 SetPos [_PosX,_POsY];

       False

       };

You could write the same code like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">WaitUntil

       {

       _Obj01 SetPos [((GetPos _ParentObj) Select 0)+(Sin (GetDir _ParentObj)*100),((GetPos _ParentObj) Select 1)+(Cos (GetDir _ParentObj)*100)];                        

       _Obj02 SetPos [((GetPos _ParentObj) Select 0)+(Sin (GetDir _ParentObj)*120),((GetPos _ParentObj) Select 1)+(Cos (GetDir _ParentObj)*120)];                        

       False

       };

I personally prefer the first example, as your not making multiple calls to GetPos and GetDir, when you don't need to. Also it appears to reduce the amount of calls to the select command to. But I would be hard pressed to see the difference in performance in game, between both these scripts. But on the other hand, the first example creates eight local variables. For all I know about the internal workings of the Arma script engine, managing those eight extra variables in the first script, could be more processor intensive then the second script? So you can see how difficult it is to give advice based on something other than personnel preference.

Another thing I noticed in OFP (not got round to testing it in Arma) was the way multiple conditions are handled. For example:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">WaitUntil

       {

       If ((Alive _MyCar) And ((_MyCar Distance _MyWaypoint)<10) And !(IsNull (NearestObject [_MyCar,"SoldierWB"]))) Then

               {

               .......

               };

       False

       };

In OFP, if the vehicle was destroyed, so the test to see if it was alive returned false. It would still check the conditions that follow after, even though the first condition failed. Because one of the conditions uses the NearestObject command, that could be quite bad.

So in the above example, it should be better to do it this way:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">WaitUntil

       {

       If (Alive _MyCar) Then

               {

               If ((_MyCar Distance _MyWaypoint)<10) Then

                       {

                       If !(IsNull (NearestObject [_MyCar,"SoldierWB"])) Then

                               {

                               ......

                               };

                       };

               };

       False

       };

Now the script will ignore the rest of the conditions, if the first If condition fails.

So considering all of the above, the only general advice I can think of would be:

Identify the commands that can visible slow the game down, and take care where and how you use them.

Think twice about any command you place within a loop, that has little or no delay. Consider if it really needs to be contained within that loop.

There are other issues regarding the inner workings of the Arma script engine, for example variable name length. Long or short, does it matter as far as processing time goes? But we could speculate over these forever, so go with personnel preference. If in doubt, post an example. There will always be plenty of people up for debating the pros and cons, so you probably won't be short of opinions smile_o.gif

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  

×