notproplayer3 5 Posted April 9, 2018 This might be a stupid question but is it possible to do a "while{} do {}" or "for{}do{}" or "if{}then{}" loop that executes the code during a specified amount of time Share this post Link to post Share on other sites
stanhope 411 Posted April 9, 2018 These are the wiki pages you want to look into:https://community.bistudio.com/wiki/while https://community.bistudio.com/wiki/for https://community.bistudio.com/wiki/if https://community.bistudio.com/wiki/time https://community.bistudio.com/wiki/sleep 1 Share this post Link to post Share on other sites
POLPOX 778 Posted April 9, 2018 for "_i" from X to Y do {} If X == 0, Y == 9, it'll execute 10 times 1 Share this post Link to post Share on other sites
notproplayer3 5 Posted April 9, 2018 I'm sorry if I wasn't clear but I meant for X time in seconds Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted April 9, 2018 8 minutes ago, notproplayer3 said: This might be a stupid question but is it possible to do a "while{} do {}" or "for{}do{}" or "if{}then{}" loop that executes the code during a specified amount of time Something like this maybe? _test = [] spawn { _duration = 10; _timeOut = time + _duration; while {time < _timeOut} do { systemchat format ["The time is: %1",round time]; sleep 1; }; systemchat "Done."; }; Cheers 1 Share this post Link to post Share on other sites
notproplayer3 5 Posted April 9, 2018 Yes, indeed it works, to be honest I thought there was some command in the game that made this more simple to do, but I won't complain more, anyways thanks a lot to all of you Share this post Link to post Share on other sites
HazJ 1289 Posted April 9, 2018 You can also use a boolean variable. Something like: someVariable = true; while {someVariable} do // while someVariable is true { // code sleep 10; }; In another file set to false. This method may not be the best approach, all depends on what you are doing and where, in which files, etc... Another way is for loop with step (set to 10 or whatever). Check Wiki. 1 Share this post Link to post Share on other sites
notproplayer3 5 Posted April 11, 2018 I see, thanks a lot Share this post Link to post Share on other sites