Home   Help Search Login Register  

Author Topic: Unknown Scripting Error  (Read 1685 times)

0 Members and 1 Guest are viewing this topic.

Offline Rommel92

  • Members
  • *
Unknown Scripting Error
« on: 13 Apr 2008, 12:28:03 »
Code: (nil = (DC3X,ShilkaX) execVM "aaa.sqf") [Select]
private ["_bool","_veh","_pos","_bul","_vel"];

_veh = vehicle _this select 0;
_src = vehicle _this select 1;
_bool = 1;

while {_bool == 1} do
{
If !(alive _veh) then {_bool = 0;};
If !(alive _src) then {_bool = 0;};

_vel = velocity _veh;
_pos = [(getpos _veh select 0) + (_vel select 0) * 4.5 + (random 20),(getpos _veh select 1) + (_vel select 1)  * 4.5 + (random 20),(getpos _veh select 2) + (_vel select 2) * 4 + 70 + (random 20)];
_bul = "GrenadeHandTimed" createVehicle _pos;
_bul setpos _pos;
sleep 0.6;
};

ERROR: Type Array, expected Object
...help.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: Unknown Scripting Error
« Reply #1 on: 13 Apr 2008, 13:34:05 »
Might be a typo here:
Code: [Select]
nil = (DC3X,ShilkaX) execVM "aaa.sqf"
should be
Code: [Select]
nil = [DC3X,ShilkaX] execVM "aaa.sqf"

And as you pass vehiclenames (i guess), whats the matter with the vehicle command?
Code: [Select]
_veh = vehicle _this select 0;
_src = vehicle _this select 1;
What happens if you put this instead?
Code: [Select]
_veh = _this select 0;
_src = _this select 1;

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Unknown Scripting Error
« Reply #2 on: 13 Apr 2008, 13:47:47 »
Code: [Select]
(DC3X,ShilkaX) execVM "aaa.sqf" ->
Code: [Select]
[DC3X,ShilkaX] execVM "aaa.sqf"
What myke said about vehicles and
Code: [Select]
If !(alive _veh) then {_bool = 0;}; ->
Code: [Select]
If (!alive _veh) then {_bool = 0;};

Offline Rommel92

  • Members
  • *
Re: Unknown Scripting Error
« Reply #3 on: 13 Apr 2008, 21:43:53 »
The fact it says (DC3X,ShilkaX) was because the (code) bracket wouldn't allow [ ], it changed one to ( and left the other ]. (Strange?)

The reason for "vehicle _this select 0" is because velocity of the player for example inside the plane would be [0,0,0], unless i placed vehicle _this select 0. The AAA source is not tested, and hence a copy paste of _this select 0, because I can't even get the script to run, I kind've dodged the initial error when I first did [DC3] just to get on with it, but now when I need it, its buggering up.

It works with
Code: [Select]
nil = DC3X execVM "AAA.sqf"

_veh = _this
however not with any form of array, ie:
Code: [Select]
nil = [DC3X] execVM "AAA.sqf"

_veh = _this select 0;

I've never seen this error before?

Code: [Select]
If (!alive _veh) then {_bool = 0;};
Code: [Select]
If !(alive _veh) then {_bool = 0;};Same thing. Both work, I just prefer it outside the bracket.

EDIT:

I have made progress, naturally it is working, however only if I remove the 'vehicle' pre-ceeding the _this select 0, which then makes  the script not work.  :blink:
« Last Edit: 13 Apr 2008, 23:51:15 by Rommel92 »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Unknown Scripting Error
« Reply #4 on: 14 Apr 2008, 10:47:19 »
Try with:
Code: [Select]
vehicle (_this select 0)

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Unknown Scripting Error
« Reply #5 on: 14 Apr 2008, 15:54:09 »
Mandoble's last post shows why you were getting the array/object error originally.

This is more of a stylistic correction rather than a logical one. We have a proper boolean type in ArmA, so you can use true and false rather than 0 and 1 to represent boolean states (the latter is only standard practice in languages without an in-built boolean type, such as C).

Code: [Select]
_bool = true;

while { _bool } do
{
If !(alive _veh) then {_bool = false;};
If !(alive _src) then {_bool = false;};

Also, do you realise that your code will create a grenade even 0.6 seconds after either _veh or _src are dead? Perhaps you would find this more useful (I don't really understand what you are trying to achieve, so sorry if this isn't correct for your requirements):
Code: [Select]
while { (alive _veh) and (alive _src) } do
{
_vel = velocity _veh;
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Rommel92

  • Members
  • *
Re: Unknown Scripting Error
« Reply #6 on: 15 Apr 2008, 04:37:08 »
Its a simulated Flak in a DC3, so the shots after aren't all that bad. But thanks for the help, and I don't know why I didn't think of a while {alive} loop, just didn't pop into me head obviously, most likely because I hadn't realised it would kill the plane so quickly.  :whistle:

My experience with Booleans are horrible, which is the main reason I still use 0's and 1's.

In any case, it now works... don't ask me how, it just... does, maybe something was conflicting somewhere, but but it works nice and clean now...

Code: [Select]
private ["_veh","_src","_vel","_pos","_bul"];

_veh = _this select 0;
_src = _this select 1;

while { (alive _veh) and (alive _src) } do
{
_vel = velocity _veh;
_pos = [(getpos _veh select 0) + (_vel select 0) * 4.5 + (random 20),(getpos _veh select 1) + (_vel select 1)  * 4.5 + (random 20),(getpos _veh select 2) + (_vel select 2) * 4 + 70 + (random 20)];
_bul = "GrenadeHandTimed" createVehicle _pos;
sleep 0.6;
};
« Last Edit: 15 Apr 2008, 08:30:15 by Rommel92 »