View Full Version : How does "sleep" work?
I thought it would be a matter of code; sleep(); code. But this doesn't work.
See sleep command in the Biki (http://community.bistudio.com/wiki/sleep)
you need to specify the sleep period in seconds
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">blablabla...
sleep 10
/*sleeps for 10 seconds*/
blablabla[/QUOTE]
whats it do tho? is it not the same as ~6
benreeper
Dec 6 2006, 15:19
It's ~ for functions.
--Ben
I'm making an intro for a mission, but I don't know how to delay the next camcommit.
To delay the camcommit use
~10
or ~ and the time to wait.
I thought they changed the ~ in arma
They only changed it for functions. In the case of functions you use the sleep command. In a general script you can continue to use ~.
Hoz
Whenever I use it I get "error invalid number in expression".
Am I not supposed to use it like this: blablabla; ~10; blablabla
You should not use old style SQS scripts, executed with exec command, in ArmA. Instead you should use the new SQF scripts executed with execVM/spawn, where the sleep command must be used. The sleep command does not work in functions since it would freeze the whole game.
Look here (http://community.bistudio.com/wiki/Controlling_program_flow) for an example of how the script syntax has changed.
i tried using execVM but it comes up with an error and wanted me to use exec http://forums.bistudio.com/oldsmileys/huh.gif
This has got me totaly confused with scripting again, after a long time i got oki with it now im totaly confused lol http://forums.bistudio.com/oldsmileys/sad_o.gif
I knew this would happen http://forums.bistudio.com/oldsmileys/smile_o.gif Tilde is only used with the old exec command, which is pretty much obsolete now. If your using execVM (http://community.bistudio.com/wiki/execVM) or spawn (http://community.bistudio.com/wiki/spawn) you need to use sleep (http://community.bistudio.com/wiki/sleep).
Text files, containing arma commands, executed with execVM (http://community.bistudio.com/wiki/execVM) or spawn (http://community.bistudio.com/wiki/spawn) work exactly the same way that the old "scripts" did in OFP. The wiki calling them functions, is just misleading IMHO.
Functions in OFP have specific functionality compared to the old style scripts. They are executed sequentially, they can return values to the calling routines and they can't be paused. The same still stands with Arma.
In Arma there are some similarities between functions and "scripts", but it's so trivial, it's not worth mentioning for most peoples requirements. I can see many a scripting thread filling up with these kind of misunderstandings.
All the wiki needs to say is:
Scripts now share the same syntax as functions, but still behave in exactly the same way as thier OFP counterparts. However they are now called using execVM (http://community.bistudio.com/wiki/execVM) or spawn (http://community.bistudio.com/wiki/spawn).
At least it sounds sensible to me?
There's 1 similarity between ArmA functions & scripts that is all but trivial : they share the same syntax!
And I think most of the issues will come from this : people will try to use old OFP-style syntax and it will cause errors (see Matt Rochelle post above)
In fact, it's very simple :
- scripts should not be written like they were in OFP .sqs scripts. They should be written using the new syntax (which is the same than the syntax used in OFP & ArmA functions, called by "call"), and called through "spawn" and "execVM".
- if you want to use old style syntax, launch your script with the "exec" command. But it is not recommended (and moreover, "new style" syntax is imho clearer)
New syntax includes "sleep" instead of "~", "if ... then... else" instead of "?(...):...", things like that.
do we have a command refrence with all these in detail whats changed between the things so we have some idea how to make and edit new scripts http://forums.bistudio.com/oldsmileys/huh.gif
CrashDome
Dec 7 2006, 14:42
do we have a command refrence with all these in detail whats changed between the things so we have some idea how to make and edit new scripts http://forums.bistudio.com/oldsmileys/huh.gif
Isn't that what the biki is for?
Or maybe you are asking if there exists anything detailing the changes now? If that's your question... then NO... there isn't... we need to begin making notes within the commands listed on the biki to help people make the distinction between OFP and ArmA.
That is something I haven't seen yet... nobody is making notes on the biki of their findings... they are posting them here again in the threads which means they will be lost 3 months from now.
Yeah, there needs to be a central check list for converting old scripts to new e.t.c
Things like "" being replaced with {} when used with the call command e.t.c
Also a comprehensive description, on the differences between the Call (http://community.bistudio.com/wiki/call_code), ExecVM (http://community.bistudio.com/wiki/execVM) commands and how they handle code and operate within the game.
Quote[/b] ]There's 1 similarity between ArmA functions & scripts that is all but trivial : they share the same syntax!
Perhaps I sould have elaborated? If an Arma script does not contain the sleep (http://community.bistudio.com/wiki/sleep) command, or tries to return a value, then the same peice of code can be called with Call (http://community.bistudio.com/wiki/call_code), ExecVM (http://community.bistudio.com/wiki/execVM) or spawn (http://community.bistudio.com/wiki/spawn). Previously in OFP, you could not share code in quite the same way.
I think it's rare that anyone would want to use either Call (http://community.bistudio.com/wiki/call_code) or spawn (http://community.bistudio.com/wiki/spawn) on the same chunck of code, thats why I used the word trivial.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.