Jump to content
Sign in to follow this  
JayRoe

How does "sleep" work?

Recommended Posts

I thought it would be a matter of code; sleep(); code. But this doesn't work.

Share this post


Link to post
Share on other sites

See sleep command in the Biki

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

Share this post


Link to post
Share on other sites

I'm making an intro for a mission, but I don't know how to delay the next camcommit.

Share this post


Link to post
Share on other sites

To delay the camcommit use

~10

or ~ and the time to wait.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Whenever I use it I get "error invalid number in expression".

Am I not supposed to use it like this: blablabla; ~10; blablabla

Share this post


Link to post
Share on other sites

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 for an example of how the script syntax has changed.

Share this post


Link to post
Share on other sites

i tried using execVM but it comes up with an error and wanted me to use exec 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 sad_o.gif

Share this post


Link to post
Share on other sites

I knew this would happen smile_o.gif Tilde is only used with the old exec command, which is pretty much obsolete now. If your using execVM or spawn you need to use sleep.

Text files, containing arma commands, executed with execVM or 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 or spawn.

At least it sounds sensible to me?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 huh.gif

Share this post


Link to post
Share on other sites
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  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.

Share this post


Link to post
Share on other sites

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, 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 command, or tries to return a value, then the same peice of code can be called with Call, ExecVM or 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 or spawn on the same chunck of code, thats why I used the word trivial.

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  

×