Tanelorn 0 Posted December 11, 2002 Re: to SUMA and others. Using ~.0001 still causes the script to loop alot and burden the CPU. Its a better idea, but I'm suprised you recommend a loop that runs so often. In my scripts, I use a toggle and @ statements to reduce the burden. example (not in proper syntax, only for example): #geardrop @(height myhelo < 5 AND speed myhelo < 10) myhelo animate ["gear", 1] goto "gearraise" #gearraise @(height myhelo > 5 OR speed myhelo > 10) myhelo animate ["gear",0] goto "geardrop" This code really reduces CPU burden because it waits until a specific event before continuing. It only needs to check for raising when the gear is already down, and visa versa. This way, it is very efficient with no repetetive looping. Oh, and sharpshooter. use the ABS command. It automatically converts negative numbers to positive ones, it will save you trouble in your if statements. example: ?( speed myvehicle > 10 OR speed myvehicle < -10) can be: ?( (abs(speed myvehicle)) > 10) Share this post Link to post Share on other sites
The Sharpshooter 0 Posted December 11, 2002 Thanks Tanelorn for the help, but something isn´t clear. There isn´t such command "height", I think that you need to get the helo position from constant looping anyways. Otherwise I don´t now how this "@" work. Can you be more clear on that ? The "abs" command helped me a lot, i got it working OK with that command. Thanks for the help. Share this post Link to post Share on other sites
colonel_klink 0 Posted December 11, 2002 Thanks Suma.. My knowledge has been expanded once more. I presume the 0.0001 and @ statements are like the doevents I use in VB coding. Where they allow the code to check for other events to fire. Are there other ways in which we could utilise these scripts that reduce the cpu usage? Share this post Link to post Share on other sites
The Sharpshooter 0 Posted December 12, 2002 I found another thing, the "Land Contact" LOD can also be animated. This means that the gear will work 100% now.The question is which is better ? The gear that is controlled by the player or the gear that is controled by the machine... Any suggestions ? Share this post Link to post Share on other sites
The Sharpshooter 0 Posted December 12, 2002 Another problem, I tried to add localize "STR_ACTION_GEAR_DOWN" to "displayname" under a class of animation. It doesn´t work. I want to read the text form BIS Stringtable so it can support different languages. Thanks. Share this post Link to post Share on other sites
Guest BratZ Posted December 12, 2002 whenever I have used the @,I noticed considerable cpu load Share this post Link to post Share on other sites
suma 8 Posted December 12, 2002 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Tanelorn @ Dec. 11 2002,19:26)</td></tr><tr><td id="QUOTE">Using ~.0001 still causes the script to loop alot and burden the CPU. Its a better idea, but I'm suprised you recommend a loop that runs so often. In my scripts, I use a toggle and @ statements to reduce the burden.<span id='postcolor'> The ~0.001 is very easy to add into any existing script without having to restructure it - that is why I recommend it. Your solution with @ conditions will beform better, but the difference will be mostly marginal, because ~number test is very fast - and it guarantees loop will not be executed more than once in any simulation frame. Moreover, in many practical situations you can use something like ~0.1 or ~0.5 in your checking loops, and then it will be very likely less CPU intensive than using @, because no expression evaluation will be done in several simulation frames. My bottom line is: Never make infinite "checking" loop without any ~ or @ condition. Share this post Link to post Share on other sites
suma 8 Posted December 12, 2002 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (The Sharpshooter @ Dec. 12 2002,03:06)</td></tr><tr><td id="QUOTE">I tried to add localize "STR_ACTION_GEAR_DOWN" to "displayname" under a class of animation. It doesn´t work. I want to read the text form BIS Stringtable so it can support different languages.<span id='postcolor'> Expression are not evaluated inside of config string entries, therefore localize "STR_ACTION_GEAR_DOWN" cannot work. You can use displayName="$STR_ACTION_GEAR_DOWN" instead (you can check Commented config available on the Breathe page for many examples). Share this post Link to post Share on other sites
brsseb 0 Posted December 12, 2002 ok, this might be on the edge of offtopic, but i have noticed that you have always called scripts with the Init-handler. And in these scripts you have some sort of IF..THEN formula with following animations. I just wondered if its possible to start an animation without a script (no sqs file), you know, just like in UserAction class where you are able to start a series of animaitons? Here is what I tried, but it wont work. I just need to make this animation execute at startup: class eventhandlers { init = [_this select 0] Animate [""tail_wheel_door_left"", 1]; }; brsseb Share this post Link to post Share on other sites
suma 8 Posted December 12, 2002 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (brsseb @ Dec. 12 2002,16:41)</td></tr><tr><td id="QUOTE">class eventhandlers { init = [_this select 0] Animate [""tail_wheel_door_left"", 1]; };<span id='postcolor'> Aside from several syntax error, I think your approach is correct. My attempt would be: class eventhandlers { init = "(_this select 0) Animate [""tail_wheel_door_left"", 1]"; }; Explanation: 1) left argument of animate is object, not array of objects. 2) init string value must be enclosed in double quotes, as it contains spaces Note: There is no guaranntee this code will work exactly as it is, I just repaired two of your bugs, and there might be some more. Share this post Link to post Share on other sites
brsseb 0 Posted December 12, 2002 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Suma @ Dec. 12 2002,18:55)</td></tr><tr><td id="QUOTE"></span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (brsseb @ Dec. 12 2002,16:41)</td></tr><tr><td id="QUOTE">class eventhandlers { init = [_this select 0] Animate [""tail_wheel_door_left"", 1]; };<span id='postcolor'> Aside from several syntax error, I think your approach is correct. My attempt would be: class eventhandlers { init = "(_this select 0) Animate [""tail_wheel_door_left"", 1]"; }; Explanation: 1) left argument of animate is object, not array of objects. 2) init string value must be enclosed in double quotes, as it contains spaces Note: There is no guaranntee this code will work exactly as it is, I just repaired two of your bugs, and there might be some more.<span id='postcolor'> Works perfect. Thankz! Share this post Link to post Share on other sites
Tanelorn 0 Posted December 12, 2002 Thanks for working with us throughout this topic Suma. Your knowledge really helps everyone who reads this make better and more complex addons. I didn't realize that @ caused cpu burden. In the future I will use timed loops instead. Share this post Link to post Share on other sites
The Sharpshooter 0 Posted December 13, 2002 Yeah, thanks Suma without your advise I guess it would had taken me hours of trial and error. I also want to thank all the people that helped me to get the Gear thingy working. Sharpshooter. Share this post Link to post Share on other sites