Jump to content
Sign in to follow this  
jetplane_pete

getting object position and

Recommended Posts

Guys hi

Excuse the simple language but computer wiz I'm not.

I want to take a know position, (I have tried with a gamelogic, a unit and a marker) and enter it into a script so that a "setpos" command will then move a unit there.

I can run it when using the object name, but as soon as I try and take it as a variable so that the same script can be used for different object locations I run into trouble.

I have tried so many different snippets I won't bother the put them here.

Any one help

thanx

P

Share this post


Link to post
Share on other sites

Well the simpliest form is to create a marker and spawn the unit to the position. Give the marker a name, in my example "marker_name"

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit setPos (getMarkerPos "marker_name")

If you want to create several markers and want to spawn the unit to one of them, you could create several markers (my example: "marker1","marker2","marker3") and join them in an array in an unit's init field or the init.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">SPAWN_MARKERS = ["marker1","marker2","marker3"]

In an other script you could use this array to pic one of the three positions at random

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

_i = random _c

_unit setPos (getMarkerPos (SPAWN_MARKERS select _i))

These are just ideas, since I don't understand exactly what your problem is. wink_o.gif

Share this post


Link to post
Share on other sites

I'll try again to describe what I'm after.

Take several known positions - call them sw1, sw2 etc

Each of them has a trigger over it, and I want the trigger to run a script.

so when trigger1 goes off the position of sw1 is carried into the script, but when trigger2 (or 3, etc) goes off the position for sw2, sw3 etc is carried into the script.

in otherwords the marker postion is part of the script arguement.

Have tried [sw1] exec "move.sqs" in the trigger

with the script being

;move.sqs

_se = _this select 0

player setpos [getpos _se]

exit.

I have tried loads of varients, but can't find a way to convert the sw postion into the _se variable.

the above makes perfect sense to me, but I suspect is total garbage to everybody else sad_o.gif

P

Share this post


Link to post
Share on other sites

try:

player setpos (getpos _se)

i.e. use paranthesis instead of brackets

Share this post


Link to post
Share on other sites

nah you have to use another function with markers. say the marker of trigger1 is called sw1, then write into the trigger activation:

["sw1"] exec "whatever.sqs"

script:

_marker = _this select 0

_unit setPos (getMarkerPos _marker)

Share this post


Link to post
Share on other sites

I don't think he was talking strictly about markers...

but you are correct, if it is a marker... then it's not 'getpos' it is 'getmarkerpos' but that can all be found in the comref...

Share this post


Link to post
Share on other sites

Just so you know why you example wasn't working pete. When you call the getpos command it returns an array (for expample: [1243, 2434, 2]), you actually created an array within an array (for example: [[1243, 2434, 2]]) which is the incorrect format for the setpos command.

RED

Share this post


Link to post
Share on other sites

Guys hi

Thanks for the help.

Only problem is I was talking rubbish crazy_o.gif

I'm adding an action via a script "rooment.sqs"

;rooment.sqs

; enter room

player addaction["Enter Room", "room.sqs"]

via a trigger. No problem there. With "room.sqs" running if the player selects the action

However I want to enter the script arguement "sw1" from the trigger into "room.sqs". (in otherwords the arguement for "rooment.sqs" needs to be carried forward into "room.sqs"

Can this be done ?

thanx

P

Share this post


Link to post
Share on other sites

In your triggers activation field put something like:

Room = sw1; player addaction["Enter Room", "room.sqs"]

Then your room.sqs would look something like:

_unit = _this select 0

_unit setPos (getpos Room)

RED

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  

×