Need help with script not saving

The place to discuss scripting and game modifications for X²: The Threat.

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

planetx32
Posts: 7
Joined: Thu, 19. Feb 04, 01:44
x3

Need help with script not saving

Post by planetx32 » Mon, 16. May 11, 20:19

When I try to save the code with all lines active, it will ask if I want to save as normal, but it will not save. What is odd is that I can run the code as written, and can reaccess it in the game, but the game will not update the .xml file, so the next time I play the game, the script is not there.
A few of the lines of script have been commented out, and now I can save the file, so I was wondering what is with those few lines that is causing this issue.
Lines 12,14,15,17,19, and 34 are the lines of issue. Commented out, the script will save properly, but uncommented, it will not.

001 $myship = get player ship
002 $sector = $myship -> get sector
003 $loop = 0
004 $counter = 0
005 $credits = 0
006 $Stationarray = $sector -> get player owned station array from sector
007 * Creates array of all player owned ships in sector.
008 $arraysize = size of array $Stationarray
009 * Calculates the number of stations listed in the array.
010 while $loop < $arraysize
011 $station = $Stationarray[$loop]
012 *if $station == Bacon Corporation Shipyard(Bala Gi's Joy)
013 * This station exempt from deposits
014 *else if $station == Bacon Corp. Savings and Loan(Bala Gi's Joy)
015 *$Bank = $station
016 * This station serves as bank, thus exempt from depositing.
017 *else if $station == Bacon Corp. Trading Station(Bala Gi's Joy)
018 * This station exempt from deposits
019 *else
020 $Deposit = $station -> get money
021 * Any other station - gets station balance.
022 if $Deposit > 0
023 * If the station balance is greater than 0, continue.
024 $credits = $credits + $Deposit
025 * Adds station balance to total deposits.
026 write to player logbook: printf: fmt='%s has deposited %s credits.', $station, $Deposit, null, null, null
027 * Writes station name and amount transferred to player logbook
028 $Deposit = 0 - $Deposit
029 $station -> add money: $Deposit
030 * Subtracts deposit from station, leaving zero balance
031 inc $counter =
032 * Counter used to keep track of how many stations have deposits.
033 end
034 *end
035 inc $loop =
036 end
037 $Bank -> add money: $credits
038 $Deposit = $Bank -> get money
039 write to player logbook: printf: fmt='%s stations have deposited %s credits. %s holds %s credits.', $counter, $credits, $Bank, $Deposit, null

Thank you for any assitance provided.

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

Post by X2-Illuminatus » Mon, 16. May 11, 21:47

You mustn't reference specific objects that might only be present in your current save game. In your case that are the Bacon Corp. stations.
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!

planetx32
Posts: 7
Joined: Thu, 19. Feb 04, 01:44
x3

Post by planetx32 » Mon, 16. May 11, 22:25

What is odd is that the code works ingame, just won't save. Is there any sort of work-around to this so that I can still exclude certain stations?

User avatar
Zeron-mk7
Posts: 571
Joined: Sat, 23. Feb 08, 12:38
x3

Post by Zeron-mk7 » Tue, 17. May 11, 07:49

planetx32 wrote:012 *if $station == Bacon Corporation Shipyard(Bala Gi's Joy)
013 * This station exempt from deposits
014 *else if $station == Bacon Corp. Savings and Loan(Bala Gi's Joy)
015 *$Bank = $station
016 * This station serves as bank, thus exempt from depositing.
017 *else if $station == Bacon Corp. Trading Station(Bala Gi's Joy)
Just to be sure - Bacon Corporation Shipyard(Bala Gi's Joy), Bacon Corp. Savings and Loan(Bala Gi's Joy) and Bacon Corp. Trading Station(Bala Gi's Joy) are not from vanilla X2, these stations are from X3.
Maybe you posted in wrong forum ?

P. S. Unfortunately, I don't know about scripting, so can't help with scripting.
Image

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

Post by X2-Illuminatus » Tue, 17. May 11, 09:12

Is there any sort of work-around to this so that I can still exclude certain stations?
Sure, you just have to search for these stations more generally. Meaning, check for their object classes, their waretype code or their subtype. For the latter an example could look like:

Code: Select all

001   $sector = get sector from universe index: x=1, y=3
002   $stat.arr = $sector -> get station array from sector
003   $size.stat.arr =  size of array $stat.arr
004   while $size.stat.arr
005    dec $size.stat.arr = 
006    $station = $stat.arr[$size.stat.arr]
007    $subtype =  get subtype of ware $station
008    if $subtype == 48462
009   * do something
010    end
011   end
012   return null
This would "do something", if a Free Argon Trading Station is found in Argon Prime (sector coordinates x=1, y=3).
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!

planetx32
Posts: 7
Joined: Thu, 19. Feb 04, 01:44
x3

Post by planetx32 » Tue, 17. May 11, 21:20

The stations are from vanilla X2, just renamed to my twisted preference.

Thank you all for the tips. I shall give it another try.

Return to “X²: The Threat - Scripts and Modding”