OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Rommel92 on 27 May 2008, 04:33:06

Title: Generic Error in Expression
Post by: Rommel92 on 27 May 2008, 04:33:06
I could kill ArmA.  :yes:

Code: [Select]
_para = _this select 1;
_var = _this select 3;
_pos = _this select 4;

switch (_var) do
{
case 0:
{
onMapSingleClick "[[],Player,[],1,_pos] call ROMM_fPara; true;";
};
case 1:
{
_chute = "ParachuteC" createVehicle _pos;
_chute setPos [_pos select 0, _pos select 1,(_pos select 2) + 300];
_para moveInDriver _chute;

While {((getpos _chute) select 2) > 7} do
{
if (vehicle _para != vehicle _chute) then
{
_para moveInDriver _chute;
};
sleep 1.75;
};
};
};

A new para script for a mission I'm making, error is at the "sleep 1.75;". (Generic Error in Expression)
The code works without this, but naturally I want a sleep in the while loop... I have the exact same structure in another script and it works right, and I cannot find any reason for this.

EDIT: From Further Testing, I have also revealed the While loop only runs once, despite the fact the chute is 160m in the air (also, chute is 160m in air, not 300...  :weeping:)"

 :dunno:
Title: Re: Generic Error in Expression
Post by: Mandoble on 27 May 2008, 10:46:22
onMapSingleClick "res=[[],Player,[],1,_pos] execVM ""ROMM_fPara.sqf""; true;";
Title: Re: Generic Error in Expression
Post by: Rommel92 on 27 May 2008, 11:07:09
I don't understand? Does it matter how its executed in to why it is giving this error?  :dunno:
Title: Re: Generic Error in Expression
Post by: i0n0s on 27 May 2008, 17:38:42
call doesn't allow the use of sleep, waitUntil etc.
So you have to use spawn instead.
And which method do you use to launch the script?
Title: Re: Generic Error in Expression
Post by: Mr.Peanut on 27 May 2008, 20:28:08
Another recursive sqf script?  :no:
Title: Re: Generic Error in Expression
Post by: Rommel92 on 28 May 2008, 23:42:06
call doesn't allow the use of sleep, waitUntil etc.

This is untrue, I use many scripts (infact almost all) with call and I use sleeps in them and they work. Check latest version of ROMM_fMorale for a good example.
Code: [Select]
_Events_Unit_S = [
[],
[],
[],
[],
[],
["[_group] call ROMM_fMorale"]
];
This works a dream, yet you say that WaitUntils/Sleeps (delays in general?) won't work. I beg to differ.

 :good:

And which method do you use to launch the script?

I use (flagPole addaction ["ParaJump","ROMM_fPara.sqf",0])

Title: Re: Generic Error in Expression
Post by: i0n0s on 29 May 2008, 11:21:53
Ok, as far as I read, you're allowed to use any delay. But I still thinks that it's wrong at that point.

But first to a fault:
onMapSingleClick "[[],Player,[],1,_pos] call ROMM_fPara; true;"
The last ';' has to get removed because true should be a return value. Currently there is no return value and according to Biki that will raise an error message:
Quote
In such case default processing by the game engine is done, and error message may be displayed

But nevertheless:
onMapSingleClick has to wait until player hit the ground. If you use spawn it don't has to wait and your script still runs.
Title: Re: Generic Error in Expression
Post by: Rommel92 on 29 May 2008, 13:47:27
Code: [Select]
_para = _this select 1;
_shift = _this select 2;
_var = _this select 3;
_pos = _this select 4;

switch (_var) do
{
case 0:
{
titleCut ["Shift - Click your DropZone on the Map.","PLAIN DOWN",3];
onMapSingleClick "[[],Player,_shift,1,_pos] call ROMM_fPara; true;";
};
case 1:
{
if (_shift) then
{
onMapSingleClick "";
_chute = "ParachuteC" createVehicle _pos;
_chute setPos [_pos select 0, _pos select 1,(_pos select 2) + 300];
_para moveInDriver _chute;
};
};
};

Current code, I still can't place the WaitUntil / While / Delays in there for some bizarre as reason.  ???
Title: Re: Generic Error in Expression
Post by: Wolfrug on 29 May 2008, 14:28:15
Have you TRIED it using spawn or execvm? If you don't want to compile it every time you run it (=execvm) just precompile it (GlobalVar = {your script}) and then use spawn. There are exactly two reason (as far as I can tell) for using call instead of spawn (or execvm) : 1) you want something returned from the script, as in _result = call YourMathScript or 2) You want it finished REALLY fast (call stops everything else from running while it poops out an answer). Since you're using sleep, it can't be b), and since there doesn't seem to be any return value from that script, it's probably not a) either.

Anyway, I read someplace that you can only use sleeps inside called scripts if they're called from within another script. An onmapsingleclick is probably not considered that, so you might want to try first spawning/execvming a script and then calling your real script from within it...but really, that's just a hassle ;)

Wolfrug out.