WIP <RetVar/IF> <RefObj> get environment

This forum serves as MSCI Reference at EGOSOFT. It's Read-Only for non MSCI Group members.

Moderators: Scripting / Modding Moderators, MSCI Moderators

Post Reply
User avatar
Serial Kicked
Posts: 3493
Joined: Fri, 12. Aug 05, 20:46
x3tc

WIP <RetVar/IF> <RefObj> get environment

Post by Serial Kicked » Wed, 8. Sep 10, 20:26

[skip|else] if [not]|while [not]|<RetVar/IF> = <RefObj> -> get environment


[skip|else] if [not]|while [not]| = Possible 'conditional' statements that can be used.
<RetVar/IF> = variable where the requested information is put.
<RefObj> = The object you want to check.


If <RefObj> is docked, <RetVar/IF> will contain the carrier or station it is docked at, otherwise it returns the sector the object is in. If <RefObj> is invalid or doesn't exist, it will return null.

Alternatively, when the script is running on the object you want to check you can use the [ENVIRONMENT] constant.


Example:

$env = $ship -> get environment
$sector = $ship -> get sector
if $env = $sector
| write to logbook "the ship is flying"
else
| write to logbook "the ship is docked"
end


Command Location:

Alex Vanderbilt
Winner X3 Sektorquest
Posts: 2119
Joined: Thu, 4. May 06, 12:07
x3tc

[TiP][49] 286489

Post by Alex Vanderbilt » Wed, 22. Sep 10, 08:34

[skip|else] if [not]|while [not]| <RetVar> = <RefObj> -> get environment


[skip|else] if [not]|while [not]| = Eine mögliche Bedingung, die mit diesem Kommando verwendet werden kann.
<RetVar> = Die Variable, in die die Informationen abgelegt werden
<RefObj> = Das Objekt, das Du überprüfen willst.


Wenn <RefObj> gelandet ist, beinhaltet <RetVar> (die Variable) den Träger oder die Station, an dem/der es gelandet ist. Ist das Schiff nicht gelandet, gibt das Kommando den Sektor aus, in dem sich das Schiff befindet. Wenn <RefObj> ungültig ist oder nicht existiert, wird null zurückgegeben.

Alternativ kann man auch die [ENVIRONMENT]-Konstante auf dem zu überprüfenden Schiff verwenden, auf dem das Skript läuft.

Beispiel:

$env = $ship -> get environment
$sector = $ship -> get sector
if $env = $sector
| write to logbook "Das Schiff fliegt"
else
| write to logbook "Das Schiff ist gelandet"
end

Hier wird geprüft, ob $ship fliegt oder nicht. Wenn $ship fliegt, wird in das Logbuch "Das Schiff fliegt" geschrieben, andernfalls "Das Schiff ist gelandet".


Zu finden unter:

User avatar
s9ilent
Posts: 2011
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent » Wed, 22. Sep 10, 15:02

One small addition
There is a sector null, which if you ran a if $ship get environment on a ship in that null sector, it will return false.
(Similarly if the object doesn't exist and it returns null, it will also return false)
These are the only 2 conditions in which it return not enter an if condition



Also I think it should be explicitly stated that
[ENVIRONMENT] is identically equal to
[THIS]-> Get environment
(i.e. explicitly mention the word [THIS])

Post Reply

Return to “MSCI Reference”