Home   Help Search Login Register  

Author Topic: The Mysterious Case of the Unneccessary Brackets  (Read 1238 times)

0 Members and 1 Guest are viewing this topic.

Lone-Wolf

  • Guest
The Mysterious Case of the Unneccessary Brackets
« on: 16 Aug 2009, 22:08:24 »
The script editor is asking for those unneccessary brackets that when I put them in it demands they be removed.

Whenever I try to run this line:

_a setvelocity ((velocity _a select 0 + ((2 * (cos (90-(_dir))))))),((velocity _a select 1 + ((2 * (sin (90-(_dir))))))),((velocity _a select 2)-1)];

(BTW, its all on the one line rly)

The editor says: "Error: Type Any, Expected Number" (referring to the middle section of [*,*,*])
and it also says: "Error: Missing )" seemingly expecting one after the line's end.

I've stripped it apart and tried each piece seperately and found that sometimes a piece works on it's own but not in the line as a whole or that when I run the script it spontaneously works fine and then when I run it again w/o changing anything it has a million errors!

In a nutshell:

 :weeping: :weeping: :weeping:

Help?

   Yours
         Lone-Wolf

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: The Mysterious Case of the Unneccessary Brackets
« Reply #1 on: 16 Aug 2009, 22:32:22 »
seems alright

well just introduce local vars

_var1 = 90-(_dir)
_var2 = cos(_var1)

etc


Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: The Mysterious Case of the Unneccessary Brackets
« Reply #2 on: 16 Aug 2009, 22:33:23 »
Try

Code: [Select]
_a setvelocity [(velocity _a select 0) + (2 * cos (90-_dir)), (velocity _a select 1) + (2 * sin(90-_dir)), (velocity _a select 2) -1];
Was missing opening [ and had far too many unnecessary brackets. Also, it may not make any difference but I generally have sin and cos the other way around, ie sin for x and cos for y.

Lone-Wolf

  • Guest
Re: The Mysterious Case of the Unneccessary Brackets
« Reply #3 on: 16 Aug 2009, 22:57:57 »
The latter worked fine so thanks a bunch.  :good: