OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: laggy on 16 Dec 2008, 22:08:53

Title: Easy SQF question.
Post by: laggy on 16 Dec 2008, 22:08:53
Hi everyone,

I have this sqf going:

Code: [Select]
_body = _this select 0;
_fly  = _this select 1;

while {true} do
{
   if (_fly distance _body > 3) then
{
       _fly setpos getpos _body;
} else {
       _fly setpos [(getpos _fly select 0) + (0.1 - random 0.2) , (getpos _fly select 1) + (0.1 - random 0.2), (getpos _fly select 2) + (0.1 - random 0.2)];
   };
   sleep 1;
};

I get this errormessage:

Quote
#sleep 1

error generic error in expression

Someone probably laughs at me, but I have no idea what is wrong.

Laggy
Title: Re: Easy SQF question.
Post by: Ext3rmin4tor on 16 Dec 2008, 22:13:17
It seems correct... Did you copy/pasted the code from the original one or rewrite it?
Title: Re: Easy SQF question.
Post by: laggy on 16 Dec 2008, 22:14:40
It's copied and pasted.
Title: Re: Easy SQF question.
Post by: Ext3rmin4tor on 16 Dec 2008, 22:16:28
Is the error displayed immediately or after some time? Because I remember that a While-loop has a limitation of 10000 loops before exiting and giving a generic expression error. Anyway now I try it on a test map.

EDIT: I tried and it works for me (no error displayed). Are you sure you passed the script correct parameters? In which context are you using it?
Title: Re: Easy SQF question.
Post by: laggy on 16 Dec 2008, 22:22:09
I have an effect with flies in a mission, it comes in two scripts.

deadguy is unit named that (it's a corpse)
That script is run when a player enters a trigger.
OnActivation [deadguy] exec "flies.sqs"
The SQF is then run from that script as you can see.

Code: [Select]
_body = _this select 0

_count = 0

#loop

? _count >= 100 : exit
_count = _count + 1

_fly = "HouseFly" createvehicle [(getpos _body select 0) + (2 - random 4), (getpos _body select 1) + (2 - random 4), random 2]
_fly setdir random 360
[_body,_fly] exec "randomfly.sqf"
_fly = ObjNull

~ 0.01

goto "loop"

Laggy
Title: Re: Easy SQF question.
Post by: Ext3rmin4tor on 16 Dec 2008, 22:23:08
Check the parameters you pass the script (I tested it with a M1A1 and a Harrier flying). Could you tell me the use of the script and what parameters you're passing to it
Title: Re: Easy SQF question.
Post by: laggy on 16 Dec 2008, 22:28:29
Just modified my last message to answer your questions.
Title: Re: Easy SQF question.
Post by: i0n0s on 16 Dec 2008, 22:37:17
*cry*
You started a SQF file with exec, so it will get interpreted as a SQS file.
You have to use execVM to get the SQF syntax.
Title: Re: Easy SQF question.
Post by: laggy on 16 Dec 2008, 22:39:15
 :-[

Ehhh, I said someone is laughing at me.
It works now.

Thanks both of you,

Laggy
Title: Re: Easy SQF question.
Post by: i0n0s on 17 Dec 2008, 01:54:30
:)
Title: Re: Easy SQF question.
Post by: savedbygrace on 19 Dec 2008, 11:46:59
While on this subject....Could anyone expound on what the VM is in execVM and why it must be there to distinguish SQF? Just for further understanding.  :scratch:
Title: Re: Easy SQF question.
Post by: Planck on 19 Dec 2008, 15:00:17
Well, ummm, its the name of the command to execute sqf scripts and functions as opposed to the exec command which is for sqs scripts.

ExecVM (http://ofpec.com/COMREF/index.php?action=details&id=550)
or
ExecVM (http://ofpec.com/COMREF/index.php?action=details&id=551)

as opposed to  Exec (http://ofpec.com/COMREF/index.php?action=details&id=125)

No idea what the VM actually means... maybe Virtual Machine, Very Muchly, Van Morrison, Very Meaningless ... take your pick.


Planck
Title: Re: Easy SQF question.
Post by: Ext3rmin4tor on 19 Dec 2008, 15:39:20
 :D

It's Virtual Machine



#EDIT: No need to quote the entire previous post you're replying to..    h-