<RetVar/IF><RefObj> can buy 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

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

<RetVar/IF><RefObj> can buy ware <Var/Ware>

Post by X2-Illuminatus » Fri, 8. Apr 11, 14:35

[skip|else] if [not]|while [not]|<RetVar/IF><RefObj> can buy 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 1 on success and null on failure.
<RefObj> = The station you want to check, if it can buy <Var/Ware>.
<Var/Ware> = The ware you want to check, if it can be bought by <RefObj>.


Checks, if the as <RefObj> selected station can buy the as <Var/Ware> selected ware.
This will neither check, if the selected station has enough money to buy that ware (in case it's a player own stations) nor if it has free cargo space for that ware.


Example:

$target = get player tracking aim
if $target -> can buy ware $ware
|if $target -> get free amount of ware $ware in cargo bay
||$price = $target -> get price of ware $ware
||$money = $target -> get money
||if $money >= $price
|||write to player logbook: printf: fmt='%s can buy %s.', $target, $ware, null, null, null
||end
|end
end
return null


Assuming $ware contains a ware and the current player $target is a station, this will check if that station can buy that ware. This example also checks, if the station has enough free cargo space and enough money for at least one unit of that ware. In case the station can buy the ware, an appropriate message will be written to the player logbook.


Related Commands:

<RetVar/IF><RefObj> can sell ware <Var/Ware>


Command Location:

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

[TiP][49] 299521

Post by X2-Illuminatus » Mon, 9. May 11, 18:14

[skip|else] if [not]|while [not]|<RetVar/IF><RefObj> can buy 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 1 im Erfolgs- und null im Fehlerfall enthalten.
<RefObj> = Die Station, die du darauf überprüfen möchtest, ob sie <Var/Ware> kaufen kann.
<Var/Ware> = Die Ware, von der du wissen möchtest, ob sie von <RefObj> gekauft wird.


Der Befehl überprüft, ob die als <RefObj> ausgewählte Station die als <Var/Ware> ausgewählte Ware kaufen kann.
Er wird weder überprüfen, ob die ausgewählte Station genug Geld hat, um diese Ware zu kaufen (wenn es eine Spielerstation ist), noch ob sie genügend freien Frachtraum für diese Ware hat.


Beispiel:

$target = get player tracking aim
if $target -> can buy ware $ware
|if $target -> get free amount of ware $ware in cargo bay
||$price = $target -> get price of ware $ware
||$money = $target -> get money
||if $money >= $price
|||write to player logbook: printf: fmt='%s kann %s kaufen.', $target, $ware, null, null, null
||end
|end
end
return null


Vorausgesetzt $ware enthält eine Ware und das aktuelle Spielerziel $target ist eine Station, wird dies überprüfen, ob die Station die Ware kaufen kann. Dieses Beispiel prüft ebenfalls, ob die Station genügend freien Frachtraum hat, um mindestens eine Einheit der Ware zu kaufen. Sollte dies der Fall sein, wird eine entsprechende Nachricht ins Logbuch geschrieben.


Verwandte Befehle:

<RetVar/IF><RefObj> can sell ware <Var/Ware>


Zu finden unter:

Return to “MSCI Reference”