Jump to content
Sign in to follow this  
Cougar_DK

Noob question: Result af setPosASL stored in array

Recommended Posts

Hi I'm still learning this script language and this time I want to store every units location in a array. This piece of code seems to work:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">aiInfo set [i_co, getPosASL _unit]

i_co = i_co + 1

Where i_co and aiInfo is two global variables. An integer and an array.

getPosASL gives an array with three elements and I'm then trying to get the positions this way:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x exec "somescript.sqs"} forEach aiInfo

I guess _x is now a position array, but this could be my problem...

The "somescript.sqs" looks like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_obj = _this select 0

_xpos = _obj select 0

_ypos = _obj select 1

_zpos = _obj select 2

But it seems that _obj isn't an array. Is this the way to do it or am I way out ? smile_o.gif

Share this post


Link to post
Share on other sites

i think you need the pos like this ?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_obj = _this select 0

_x=(getpos _obj select 0)

_y=(getpos _obj select 1)

_z=(getpos _obj select 2)

also and i am no expert either, when trying to retrieve info like this, if i dont put [_x] exec blah. it will return error. just a thought incase you get one with {_x exec blah.

Share this post


Link to post
Share on other sites

ok. the _x contains the pos like this [x,y,z].

In the script you have _obj = _this select 0 what means _obj = _x select 0 what means _obj = [x,y,z] select 0 and that is x. So you just have to replace _obj = _this selct 0 with _obj = _this wink_o.gif

Share this post


Link to post
Share on other sites

Thanx TD! I will try this out. I like your way of telling what I have done wrong. Makes it easier to learn! notworthy.gif

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×