[This] -> buy X units of Y - Waren werden nicht geladen

Hier ist der ideale Ort um über Scripts und Mods für X²: Die Bedrohung zu diskutieren.

Moderators: Scripting / Modding Moderators, Moderatoren für Deutsches X-Forum

Silia
Posts: 60
Joined: Mon, 10. May 04, 12:35
x2

[This] -> buy X units of Y - Waren werden nicht geladen

Post by Silia »

Ich hab ein problem mit dem Buy-Befehl.

Wenn ich folgende Zeile ausführe bekomme ich zwar die richtige Menge der gekauften Res als Rückgabewert geliefert aber es ändert sich nichts an der Menge im Laderaum des Schiffes.

$Menge = [THIS] -> buy $amount units of $Ware to a max. price of 100000 Cr

Das Schiff ist in der richtigen Sation und Geld ist an der Homebase genug da, im Laderaum ist genug platz und der Rückgabewert ist auch korrekt.
Hat einer einen Tipp warum die Ware nicht im Schiff erscheint?
User avatar
Orka
Posts: 817
Joined: Wed, 7. Apr 04, 15:19
x4

Post by Orka »

Welche Ware versuchtst du wo zu kaufen?
Silia
Posts: 60
Joined: Mon, 10. May 04, 12:35
x2

Post by Silia »

Das is in einem Versorgungsscript für Stationen.
Das Ship startet wenn es irgendwo gedockt ist (003) fliegt zur Station (009) und kauft (012)
Es passiert immer das gleiche. Der Rückgabewert im Script stimmt aber im Game werden Ladung und Credits nicht übertragen. Gesehen daß es nicht klappt hab ich bei Energiezellen, Kristallenm und Sojagrüze.

Code: Select all

Arguments
1: Ware , Var/All Wares , 'Ware' 
2: Station , Var/Station , 'in Station' 
Source Text

001   $amount = 10000
002   
003 @ = [THIS] -> call script '!move.undock' : 
004   
005   [THIS] -> set wanted ware to $Ware
006   [THIS] -> set wanted ware count to $amount
007   [THIS] -> set destination to $Station
008   
009 @ = [THIS] -> call script '!move.movetostation' :  station=$Station
010   
011   if [DOCKEDAT] == $Station
012    $txt = [THIS] -> buy $amount units of $Ware to a max. price of 100000 Cr
013    $txt = '...' + $txt
014    send incoming message $txt to player: display it=[FALSE]
015   end
016   
017   [THIS] -> set wanted ware to null
018   [THIS] -> set wanted ware count to null
019   [THIS] -> set destination to null
020   
021   return null
ticaki
Posts: 4861
Joined: Wed, 6. Nov 02, 20:31
x3

Post by ticaki »

Silia wrote:Das is in einem Versorgungsscript für Stationen.
Das Ship startet wenn es irgendwo gedockt ist (003) fliegt zur Station (009) und kauft (012)
Es passiert immer das gleiche. Der Rückgabewert im Script stimmt aber im Game werden Ladung und Credits nicht übertragen. Gesehen daß es nicht klappt hab ich bei Energiezellen, Kristallenm und Sojagrüze.

Code: Select all

Arguments
1: Ware , Var/All Wares , 'Ware' 
2: Station , Var/Station , 'in Station' 
Source Text
...
versuche es mal mit folgender Variante... aber mein Code ist aus dem Kopf...

Code: Select all

001   $amount = [this] -> get free amount of $ware in cargo bay
002   
003 @ = [THIS] -> call script '!move.undock' : 
004   
005   [THIS] -> set wanted ware to $Ware
006   [THIS] -> set wanted ware count to $amount
007   [THIS] -> set destination to $Station
008   
009 @ = [THIS] -> call script '!move.movetostation' :  station=$Station
010   
010a $price = $station -> get price of $ware
011   if [DOCKEDAT] == $Station and $price < 10000
012    $txt = [THIS] -> buy $amount units of $Ware to price $price
013    $txt = '...' + $txt
014    send incoming message $txt to player: display it=[FALSE]
015   end
016   
017   [THIS] -> set wanted ware to null
018   [THIS] -> set wanted ware count to null
019   [THIS] -> set destination to null
020   
021   return null
ich zeig dir mal wie der Teil bei mir aussieht:

Code: Select all

078   * Fuer wieviel Ware langt die Kohle
079    $StMoney = [HOMEBASE] -> get money
080    $Amount = $StMoney / $RealPrice
081   * Freies Lager im Schiff
082    $Amountofship = [THIS] -> get free amount of ware $Ware in cargo bay
083    skip if not $Amount >= $Amountofship
084     $Amount = $Amountofship
085   * ueberprueft den Lagerstand der Homebase
086    $Amountofship = [HOMEBASE] -> get free amount of ware $Ware in cargo bay
087    $TrueAmount.in.Ship = [THIS] -> get true amount of ware $Ware in cargo bay
088    $Amountofship = $Amountofship - $TrueAmount.in.Ship
089    skip if not $Amount >= $Amountofship
090     $Amount = $Amountofship
091   * Pruefen ob genug Ware in der SellStation vorhanden
092    $RealBuyAmount = $StationSellsRes -> get true amount of ware $Ware in cargo bay
093    skip if not $Amount >= $RealBuyAmount
094     $Amount = $RealBuyAmount
095   * Kaufen
096    $GotWare = [THIS] -> buy $Amount units of $Ware to a max. price of $MaxPrice Cr
Gruß ticaki
Zur Zeit nicht aktiv
Silia
Posts: 60
Joined: Mon, 10. May 04, 12:35
x2

Post by Silia »

hat sich erledigt. der fehler war woanders. das folgescript hat die Station wegen einem Tippfehler mit seiner Homebase verwechselt und die Res deswegen noch in der selben Millisekunde wieder zurückgegeben :headbang:

Return to “X²: Die Bedrohung - Scripts und Modding”