<RetVar/IF><RefObj> get price of ware <Var/Ware>

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

Moderators: Scripting / Modding Moderators, MSCI Moderators

Locked
User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 24965
Joined: Sun, 2. Apr 06, 16:38
x4

<RetVar/IF><RefObj> get price of ware <Var/Ware>

Post by X2-Illuminatus » Thu, 7. Apr 11, 21:50

[skip|else] if [not]|while [not]|<RetVar/IF><RefObj> get price of ware <Var/Ware>


[skip|else] if [not]|while [not]| = The possible 'Conditional' statements that can be used with this command.
<RetVar/IF> = Use a variable, if the command should return information. If a variable is used, it will return the price of <Var/Ware>.
<RefObj> = The station, which offers <Var/Ware>.
<Var/Ware> = The ware you want to know its price.


Returns the price of the as <Var/Ware> selected ware used by the as <RefObj> selected station.


Example:

$price = 0
* get all stations in the current player sector
$sector = [PLAYERSHIP] -> get sector
$station.arr = $sector -> get station array from sector
$size.station = size of array $station.arr
while $size.station
|dec $size.station =
|$newstation = $station.arr[$size.station]
* get the price of the ware, if the station buys it.
|if $station -> can buy ware $ware
||$new.price = $newstation -> get price of ware $ware
* Save the station, where the best price for the ware is offered.
||if $new.price > $price
|||$price = $new.price
|||$station = $newstation
||end
|end
end
* inform the player about the result
if not $station == null
|write to player logbook: printf: fmt='In sector %s the best price (%s Cr) to sell %s is offered at station %s.', $sector, $price, $ware, $station, null
else
|write to player logbook: printf: fmt='In sector %s no station buys %s. ', $sector, $ware, null, null, null
end
return null

Assuming $ware contains a ware, this will check, at which station in the current player sector the $ware can be sold at the best price.


Related Commands:

<RetVar/IF><RefObj> get average price of ware <Var/Ware>
<RefObj> set price of ware <Var/Ware> to <Var/Number> Cr


Command Location:

User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 24965
Joined: Sun, 2. Apr 06, 16:38
x4

[TiP][49] 299496

Post by X2-Illuminatus » Wed, 4. May 11, 16:47

[skip|else] if [not]|while [not]|<RetVar/IF><RefObj> get price of ware <Var/Ware>


[skip|else] if [not]|while [not]| = Die möglichen bedingten Anweisungen, die mit diesem Befehl genutzt werden können.
<RetVar/IF> = Nutze eine Variable, wenn der Befehl eine Information zurückgeben soll. Wenn eine Variable genutzt wird, wird sie den Preis von <Var/Ware> enthalten.
<RefObj> = Die Station, die <Var/Ware> nutzt oder anbietet.
<Var/Ware> = Die Ware, deren Preis du wissen möchtest.


Gibt den Preis von der als <Var/Ware> ausgewählten Ware, die von der als <RefObj> ausgewählten Station genutzt wird, zurück.


Beispiel:

$price = 0
* erfasse alle Stationen im aktuellen Spielersektor
$sector = [PLAYERSHIP] -> get sector
$station.arr = $sector -> get station array from sector
$size.station = size of array $station.arr
while $size.station
|dec $size.station =
|$newstation = $station.arr[$size.station]
* erhalte den Preis der Ware, wenn sie von der Station gekauft wird.
|if $station -> can buy ware $ware
||$new.price = $newstation -> get price of ware $ware
* Speichere die Station, die die Ware zum höchsten Preis kauft.
||if $new.price > $price
|||$price = $new.price
|||$station = $newstation
||end
|end
end
* informiere den Spieler über das Ergebnis
if not $station == null
|write to player logbook: printf: fmt='In Sektor %s wird der beste Preis (%s Cr), um %s zu verkaufen, von der Station %s angeboten.', $sector, $price, $ware, $station, null
else
|write to player logbook: printf: fmt='In Sektor %s kauft keine Station %s. ', $sector, $ware, null, null, null
end
return null

Vorausgesetzt $ware enthält eine Ware wird dies prüfen, an welcher Station im aktuellen Spielersektor die $ware zum besten Preis verkauft werden kann.


Verwandte Befehle:

<RetVar/IF><RefObj> get average price of ware <Var/Ware>
<RefObj> set price of ware <Var/Ware> to <Var/Number> Cr


Zu finden unter:

Locked

Return to “MSCI Reference”