Home   Help Search Login Register  

Author Topic: Can't fix an error message  (Read 748 times)

0 Members and 1 Guest are viewing this topic.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Can't fix an error message
« on: 03 Nov 2004, 00:18:08 »
Ok, I'm making a pretty cool explosion script, the way its supposed to work is you get each explosion its own parameters [TargetName,AmmoType,Height,Delay] and i have a problem with the height.
every time i get an error message saying "error select: Typed number expected array"
here's my script, the line it has a problem with is in bold

Code: [Select]
_Targets = _this select 0
_numTargets = count _Targets
_nTarget = _numTargets + 1

#Explode
_nTarget = (_nTarget - 1)
_delay = (_Targets select (_numTargets - _nTarget)) select 3
~_delay
_Target = (_Targets select (_numTargets - _nTarget)) select 0
_ammoType = (_Targets select (_numTargets - _nTarget)) select 1
_zpos = ((getpos _Target select 2) + (_Targets select (_numTargets - _nTarget)) select 2)
Code: [Select]
_ammoType camCreate [(getpos _Target select 0), (getpos _Target select 1), _zpos]
?(_nTarget == 0):goto "end"
goto "explode"

#end
exit

I've tried so many variations of this and nothing has worked. Any ideas?
Thanks  :help:
« Last Edit: 04 Nov 2004, 03:35:43 by Triggerhappy »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Can't fix an error message
« Reply #1 on: 03 Nov 2004, 02:50:21 »
The brackets add up but

_Targets select (_numTargets - _nTarget)) select 2

still doesn't make sense.   I think it may mean

_Targets select  -1 select 2

although I could be talking nonsense.
Plenty of reviewed ArmA missions for you to play

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Can't fix an error message
« Reply #2 on: 03 Nov 2004, 03:19:17 »
i have it set up that way so that it will work for an infinite amount of explosions

here, i'll explain it with some simple algebra:
_numtargets is the total number of elements in the main array, (that is actually a bunch of other arrays...)

_nTarget starts set to equal _numTargets

every loop, _nTarget is set to -1 of what it originally was, and then subtracted from _numTargets to get which element it is dealing with.

Ex. _numTargets = 5 targets
_nTarget = _numtarget(5)
_nTarget(5) - 1 = 4
_numtargets (5) - _nTarget (4) = 1 (second element in array)
_nTargets(now 4) - 1 = 3
_numtargets(5) - _nTarget(3) = 2 (third element)
and so on until _nTarget = 0 when it leaves the loop and exits
that's just how i figured it out (i like to work things out on my own usually)

i've worked it with a few random examples and its really simple math, that works, so it has something to do with the way i'm calling the getpos/setpos command... thanks though

EDIT: i have also tried using the getpos for the camcreate line, which didnt work either
« Last Edit: 03 Nov 2004, 03:32:17 by Triggerhappy »

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Can't fix an error message
« Reply #3 on: 03 Nov 2004, 22:27:04 »
anyone else have any ideas?

i just noticed that the error message actually says:

Error select: typed number expected array
if that helps
i'll fix that on my first post as well to avoid confusion

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Can't fix an error message
« Reply #4 on: 03 Nov 2004, 23:12:03 »
i have another easier question related to this problem:
calling this script i use:
Code: [Select]
[[choper,"FFAR",.2,1],[bomb1,"shell125",50,2],[bomb2,"shell120",0,5]] exec "explode.sqs"
counting this array should give me 3 right?
or will the count command give me all of the elements in every array in the array (12)
that may be the problem, but i don't think it does that...

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Can't fix an error message
« Reply #5 on: 04 Nov 2004, 00:06:26 »
The first element in the array _Targets is itself an array, right?


Plenty of reviewed ArmA missions for you to play

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Can't fix an error message
« Reply #6 on: 04 Nov 2004, 01:55:38 »
yeah all of the elements in _Targets are arrays

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Can't fix an error message
« Reply #7 on: 04 Nov 2004, 03:35:17 »
I've tried it like this as well, not much different, but less confusing to look at
I think for some reason its getting a single number for the variable named _array rather than getting an array, because its telling me i can't select things from a single number, but that doesnt make sense unless I'm confused about using the count command...

Code: [Select]
_Targets = _this select 0
_numTargets = count _Targets
_nTarget = _numTargets + 1

#Explode
_nTarget = (_nTarget - 1)
_array = (_Targets select (_numTargets - _nTarget))
_delay = _array select 3
~_delay
_Target = _array select 0
_ammoType = _array select 1
_zpos = (getpos _Target select 2) + _array select 2
_ammoType camCreate [(getpos _Target select 0), (getpos _Target select 1), _zpos]
?(_nTarget == 0):goto "end"
goto "explode"

#end
exit

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Can't fix an error message
« Reply #8 on: 04 Nov 2004, 11:30:21 »
I suggest you add a whole bunch of delays and hint format commands to the script so that you can see what's going on, and check the variable in each line as the line occurs.
Plenty of reviewed ArmA missions for you to play

Merl

  • Guest
Re:Can't fix an error message
« Reply #9 on: 04 Nov 2004, 14:29:27 »
IMHO your problem is that using this: [[[choper,"FFAR",.2,1],[bomb1,"shell125",50,2],[bomb2,"shell120",0,5]]] exec "explode.sqs"

You get three arrays

_this select 0 is [choper,"FFAR",.2,1]
_this select 1 is [bomb1,"shell125",50,2]
_this select 2 is [bomb2,"shell120",0,5]

your script only calls the first array

_Targets = _this select 0

nowhere in the script are the other two arrays called

Hope this helps

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Can't fix an error message
« Reply #10 on: 05 Nov 2004, 00:35:21 »
quite a lot actually, It works fine now.
one more question, quite a lot easier:

is there any way i could reduce the amount of brackets needed?
right now to call this script you need to have:
Code: [Select]
[[[first array],[second array],[etc]]] exec "explode.sqs"
i guess its not really important, but it will be less confusing for people to use...
« Last Edit: 05 Nov 2004, 01:32:11 by Triggerhappy »