snkman 351 Posted August 4, 2007 Hey guy's, since some day's im thinking about, what will need more resources? A loop or a @ ( Wait until ) So im really interested on what you think. Example: What would be better? @ Wait until <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> @player vehicle != player ----------------------------------------------- # Loop <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> #Start ? (player vehicle != player) : goto "Check ~1 goto "Start" #Check What do you think need's more resources? Share this post Link to post Share on other sites
norrin 9 Posted August 4, 2007 Once again going by intuition my feeling is SNK that a loop will use more resources as its processing more code. Â However, loops can be very useful if some other event happens that needs to be detected by the script while you are waiting. Share this post Link to post Share on other sites
snkman 351 Posted August 4, 2007 a loop will use more resources as its processing more code. Hey norrin, well yes a loop defenitly needs more code, but what exactly is a @ (Wait until) How does it works? Does it loop all the time till the condition is met? Becouse in this way a loop with a little delay would be resource friendlyer. ( I think ) Share this post Link to post Share on other sites
t_d 47 Posted August 5, 2007 @ is checking the condition in every frame so a loop is more performancefirendly if a delay is used. Better than a loop with a label would be a loop like "while do" because the label will always be searched from the beginning of the script. Share this post Link to post Share on other sites
Linker Split 0 Posted August 5, 2007 @ is checking the condition in every frame so a loop is more performancefirendly if a delay is used. Better than a loop with a label would be a loop like "while do" because the label will always be searched from the beginning of the script. I was always said to use a wait until... a loop check every tot seconds condition... anyway, you are the mater here T_D! thanks for the tip! Share this post Link to post Share on other sites
UNN 0 Posted August 5, 2007 Don't think of ~ or Sleep as some sort of magic commands. Both of these are loops and equivelent to: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">~10 Equals <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_MyTime=Time+10 @(_MyTime<=Time) <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Sleep 10; Equals <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_MyTime=Time+10; WaitUntil (_MyTime<=Time); ~ and Sleep just save you having to type out something like the above. Quote[/b] ]I was always said to use a wait until WaitUntil and While ar two different commands and should be used accordingly. But all of this has been debated since OFP and without any insight into the script engine, it will probably continue that way. Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted August 6, 2007 It depends on what's in the loop. A loop with no delay runs continously until the condition is met leaving no resources for other tasks. A waituntil loop is synched with the game's framerate and only runs one iteration per frame, so its load depends on how processor intensive the commands contained are and frame rate. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _playerPos = []; While {alive player} do { _playerPos = getPos player; Sleep 1; }; will always take less processor cycles than <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _playerPos = []; waitUntil { _playerPos = getPos player; !(alive player) }; Well, unless your framerate is <= 1 anyways, but that means you have other problems. Note that this usually isn't a big deal, and there are perfectly good reasons to synch a script with the frame rate. However, if you're running a particularly processor intensive section of code in there, it will bog the game down and eventually actually start hurting fps. Also, I should note that I've actually encountered problems with waitUntil loops at least twice. It seems that under certain conditions, the waitUntil loop tries to keep chugging along when the game is in the interupt menu. I've never bothered to isolate the exact reason it did that, but I do know that it was most definatly induced by the waitUntil command. Share this post Link to post Share on other sites