Jump to content
Sign in to follow this  
Blanco

Functions vs scripts

Recommended Posts

I dunno nothing about functions, but I know how to use them.

Some Questions about functions.

Are functions faster (CPU friendlier) then scripts with tight loops?

Why is that?

thx

Share this post


Link to post
Share on other sites

They are not CPU frendlier, they completely HOG the CPU until they are done in order to return their value to the calling script or function. The total CPU time used by such a method is shorter as it does not require context switching to another function or script during execution.

There are clear benefits and draw backs to this.

Share this post


Link to post
Share on other sites

ah, so does that mean U get faster aim in CoC UA when U use Functions rather than scripts?

Share this post


Link to post
Share on other sites

Yes for sure, but also we can return values from the functions which is extremely complicated and not very safe with scripts.

Share this post


Link to post
Share on other sites

I believe the largest advantage to functions over scripts is that functions are compiled by the server and remote systems one time at game startup. Therfore they reside in memory and are much faster to run.

Not sure how or when scripts are compiled but my belief is that they compile every time they are called (don't quote me on that one though).

I see the biggest disadvantage of functions is they do not recognize timed events (ie: ~10 or @something). If you need to sycronize or add time delays, scripts are better.

Best of all (in my opinion) is a combination of both. Helps to keeps scripts small and fast. I use scripts which make function calls - therfore taking advantage of time control with quick function execution.

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  

×