Home   Help Search Login Register  

Author Topic: Generic Error in Expression  (Read 3305 times)

0 Members and 1 Guest are viewing this topic.

Offline Rommel92

  • Members
  • *
Generic Error in Expression
« 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:
« Last Edit: 27 May 2008, 04:44:07 by Rommel92 »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Generic Error in Expression
« Reply #1 on: 27 May 2008, 10:46:22 »
onMapSingleClick "res=[[],Player,[],1,_pos] execVM ""ROMM_fPara.sqf""; true;";

Offline Rommel92

  • Members
  • *
Re: Generic Error in Expression
« Reply #2 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:

Offline i0n0s

  • Former Staff
  • ****
Re: Generic Error in Expression
« Reply #3 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?

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Generic Error in Expression
« Reply #4 on: 27 May 2008, 20:28:08 »
Another recursive sqf script?  :no:
urp!

Offline Rommel92

  • Members
  • *
Re: Generic Error in Expression
« Reply #5 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])

« Last Edit: 28 May 2008, 23:44:51 by Rommel92 »

Offline i0n0s

  • Former Staff
  • ****
Re: Generic Error in Expression
« Reply #6 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.

Offline Rommel92

  • Members
  • *
Re: Generic Error in Expression
« Reply #7 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.  ???

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Generic Error in Expression
« Reply #8 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.
"When 900 years YOU reach, look as good you will not!"