Get the station where the <ship> is docked at

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
User avatar
Joubarbe
Posts: 4796
Joined: Tue, 31. Oct 06, 12:11
xr

Get the station where the <ship> is docked at

Post by Joubarbe » Sat, 14. Dec 13, 12:27

Hi,

Simple question : I'd like to get the $station where the playership is docked at, to retrieve its ID code. Is there a built-in function for that ? I can't find it...

Thanks.

Cronos988
Posts: 691
Joined: Mon, 27. Aug 07, 12:34
x3tc

Post by Cronos988 » Sat, 14. Dec 13, 12:29

It might be <RefObj> -> get environment. This should give you either the sector or the object RefObj is in.

User avatar
Joubarbe
Posts: 4796
Joined: Tue, 31. Oct 06, 12:11
xr

Post by Joubarbe » Sat, 14. Dec 13, 12:42

Ok thanks, I just need to test if the playership is docked before get environment.

User avatar
Jack08
Posts: 2993
Joined: Sun, 25. Dec 05, 10:42
x3tc

Post by Jack08 » Sat, 14. Dec 13, 14:53

if you spesifically want the player ship, then you can use

Code: Select all

$playerEnvironment = [PLAYERSHIP]->get environment
if $playerEnvironment->is of class {Station}
  * We are docked at $playerEnvironment
end

or

if [PLAYERSHIP]->is docked
  $playerEnvironment = [PLAYERSHIP]->get environment
end
Both are acceptable, choose whichever you prefer - the second however has less instructions if the check were to fail, the first lets you use the environment in an else case if you want to do something if he is not docked, in this case the Environment would be the players sector. If you replace [PLAYERSHIP] with a argument for example $Ship, you can use the same code for any arbitrary ship passed to the script.
[ external image ]
"One sure mark of a fool is to dismiss anything that falls outside his experience as being impossible."
―Farengar Secret-Fire

Guest

Post by Guest » Sat, 14. Dec 13, 15:00

... if the script runs on the playership, you can use simply the constant [DOCKEDAT] ;)

User avatar
Joubarbe
Posts: 4796
Joined: Tue, 31. Oct 06, 12:11
xr

Post by Joubarbe » Sat, 14. Dec 13, 22:43

Thank you :)

User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube » Sat, 14. Dec 13, 23:02

JonfersonSDD wrote:... if the script runs on the playership, you can use simply the constant [DOCKEDAT] ;)
DOCKEDAT at works for any ship as long as the current script is being run on said ship. In other words, DOCKEDAT, HOMEBASE, etc. all refer to the THIS object.

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”