Jump to content
Sign in to follow this  
Goldfinger

What better?

Recommended Posts

What better to do? 6 different scripts with some

What will work faster? Six scripts (in different *.sqs files) with one condition (like @(condition)) in everyone script. Or one script with a small pause in a cycle and six conditions (like ?(contition))?

It is necessary to me maximum fast reaction of game to this conditions and high performance.

Sorry for my English. smile_o.gif

Share this post


Link to post
Share on other sites

best thing would be 1 little script with @ statement and one or two .sqf files (which are really fast in processing).

Share this post


Link to post
Share on other sites

Thank for the answer. I know that functions work with memory better. Still which of my two variants will be better?

Share this post


Link to post
Share on other sites
Guest BratZ

Faster reaction?

Definately the six scripts waiting for the condition

If you have the six conditions in a single script,the first condition may execute and skip over some of the others or what have you

And the hesitation waiting for the other lines to execute

Technically six scripts at once should run at once

You said performance...so of course this isn't the most efficient way to script

Share this post


Link to post
Share on other sites

Faster reaction for me is 6 events with a condition (if you can use event of course)

Share this post


Link to post
Share on other sites

Unfortunatley, preprocess routines are not much faster than regular scripting.  You only get a small boost because you preload the file into memory in the 'init.sqs' file, using 'preprocessFile ' or 'loadfile'.  This keeps you from having to load a given script into memory over again.  Other than that, its interpreted by the game engine like every other script.  Preprocess files are not byte compiled in any way to optimised performance.  

Quote the Eye of the Beholder

Quote[/b] ]

Suma  January 08, 2003, 13:26  

Few comments:

Quote:2. The function is then compiled (right then and there) into binary machine language, and take pride of place with all of the other functions (GetPos, SetPos, GetDir etc.) in memory for the duration

Unfortuntelly this is not true. Functions are interpreted as well. We do not have any compiler for scripting languague yet.

Quote:4. The function stays in memory until the mission ends

This may or may not be true, depending on how function is used. If you preload the function file once into a string variable (like in the init.sqs), it will really be reused. If you will load it when used (like call loadFile "anyFunction.sqf"), it will be loaded again and again, exactly as the script does.

However, there still are cool things you can do with them, like returning variables and defineing actual routines.

Probably your best bet to keep this fast and simple is to keep your conditions in one script.  Have a goto command to skip the rest if one is hit.  Ex:

#Loop

?(condition1):test1=true;goto "Continue"

?(condition2):test2=true;goto "Continue"

?(condition3):test3=true;goto "Continue"

?(condition4):test4=true;goto "Continue"

?(condition5):test5=true;goto "Continue"

?(condition6):test6=true;goto "Continue"

#Continue

~.1

goto "Loop"

If you execute more scripts and loop them, you will create a greater load on the server and clients, because you have just created six new threads (ofp jobs) for the gameengine to handle on a single processor machine.  You get a delay each time a script is loaded into memory to be executed.  Granted six scripts may not stall the server that much, but if you were to test more conditions like 100 or 200 it would impede performance.  The more scripts you run, the more lag you will recieve.  If you had 200 conditions to test, try creating 200 scripts for each condition in their own loop and 200 hundred conditions in one script in one loop.  I guarantee the one script with 200 hundred conidtions will be faster than executing 200 scripts with one condition.  Assuming your using a simple test like the example above.  Anyways, I hope some of that helps. Goodluck!

Share this post


Link to post
Share on other sites

I almost forgot to mention; Preprocess files can only be loaded from the 'init.sqs' file in a given mission folder.  This would have to be done outside of the addon, making the sqf script esentially useless to other players that download it.  I tried this in an addon and the 'preprocessfile' and 'loadfile' commands would not work.

From OFPEC:

Quote[/b] ]

Using functions

Before we get into making our own functions, lets look at how to implement functions that other people have made. There are three steps to using a function made by someone else:

1. Download and copy the function's .sqf file to your mission's directory,

2. Preprocess the function (load it into memory) in your mission's init.sqs file, and

3. Call the function whenever you need to use it, in accordance with the instructions for that particular function.

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  

×