How to properly duplicate a station?
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
-
- Posts: 57
- Joined: Sun, 25. Dec 11, 16:04
How to properly duplicate a station?
I have installed a small mod called atheism, which tries to turn off station destruction by GOD.
It does it by looping through all stations and making a copy of each.
That appears to work well for basic factories, but it fails for others.
I'm running a different mod called Naval Shuffle that changes the shipyards to look like the Argon PHQ, and I assume it does more than change appearance because after the atheism mod loop the shipyard has no ships and stations.
I got around that by adding a small check that skips stations that have no resources.
However, Naval Shuffle also adds stations that have more than one product. In Argon Prime, for example, there is now a Heavy Weapon Complex and a Light Weapon Complex, and both are supposed to produce 8 or so different lasers. After the atheism loop is done with them, they only produce one product.
I figured I can work around this in the same way as the shipyards, by adding a check whether there is more than one product. However, I can't find a way to get a list of products.
Here is the cloning portion from the atheism script:
$Type = $Factory-> get ware type code of object
* Create a new station as the exact clone of the old one.
$NewStation = create station: type=$Type owner=$Owner addto=$Sector x=$X y=$Y z=$Z
$Text = $Factory-> get name
$NewStation-> set rotation: alpha=$A beta=$B gamma=$G
$NewStation-> set name to $Text
$Serial = $Factory-> get serial name of station
$NewStation-> set serial name of station to $Serial
$NewStation-> add default wares to station/dock
$Shield = $Factory-> get true amount of ware {2 GJ Shield} in cargo bay
= $NewStation-> install $Shield units of {2 GJ Shield}
$Wares = $Factory-> get tradeable ware array from station
$Counter3 = size of array $Factories
while $Counter3
dec $Counter3
$Ware = $Wares[$Counter3]
$Amount = $Factory-> get true amount of ware $Ware in cargo bay
= $NewStation-> add $Amount units of $Ware
end
Now, I think the Counter3 initialization is bogus and should be "= size of array $Wares".
Is there a better way to create a clone station? The script then moves all docked shipes from the old station to the new station and deletes the old one.
It does it by looping through all stations and making a copy of each.
That appears to work well for basic factories, but it fails for others.
I'm running a different mod called Naval Shuffle that changes the shipyards to look like the Argon PHQ, and I assume it does more than change appearance because after the atheism mod loop the shipyard has no ships and stations.
I got around that by adding a small check that skips stations that have no resources.
However, Naval Shuffle also adds stations that have more than one product. In Argon Prime, for example, there is now a Heavy Weapon Complex and a Light Weapon Complex, and both are supposed to produce 8 or so different lasers. After the atheism loop is done with them, they only produce one product.
I figured I can work around this in the same way as the shipyards, by adding a check whether there is more than one product. However, I can't find a way to get a list of products.
Here is the cloning portion from the atheism script:
$Type = $Factory-> get ware type code of object
* Create a new station as the exact clone of the old one.
$NewStation = create station: type=$Type owner=$Owner addto=$Sector x=$X y=$Y z=$Z
$Text = $Factory-> get name
$NewStation-> set rotation: alpha=$A beta=$B gamma=$G
$NewStation-> set name to $Text
$Serial = $Factory-> get serial name of station
$NewStation-> set serial name of station to $Serial
$NewStation-> add default wares to station/dock
$Shield = $Factory-> get true amount of ware {2 GJ Shield} in cargo bay
= $NewStation-> install $Shield units of {2 GJ Shield}
$Wares = $Factory-> get tradeable ware array from station
$Counter3 = size of array $Factories
while $Counter3
dec $Counter3
$Ware = $Wares[$Counter3]
$Amount = $Factory-> get true amount of ware $Ware in cargo bay
= $NewStation-> add $Amount units of $Ware
end
Now, I think the Counter3 initialization is bogus and should be "= size of array $Wares".
Is there a better way to create a clone station? The script then moves all docked shipes from the old station to the new station and deletes the old one.
-
- Posts: 57
- Joined: Sun, 25. Dec 11, 16:04
I now changed the script to this:
while $Counter3
dec $Counter3
$Ware = $Wares[$Counter3]
if $Factory-> uses ware $Ware as product
$NewStation-> add product to factory or dock: $Ware
else if $Factory-> uses ware $Ware as primary resource
$NewStation-> add primary resource to factory: $Ware
end
This works well, but there does not appear to be an "add secondary resource to factory". Hrm.
while $Counter3
dec $Counter3
$Ware = $Wares[$Counter3]
if $Factory-> uses ware $Ware as product
$NewStation-> add product to factory or dock: $Ware
else if $Factory-> uses ware $Ware as primary resource
$NewStation-> add primary resource to factory: $Ware
end
This works well, but there does not appear to be an "add secondary resource to factory". Hrm.
- X2-Illuminatus
- Moderator (Deutsch)
- Posts: 24962
- Joined: Sun, 2. Apr 06, 16:38
That command is directly below the "add primary resource to factory" command in the Script Editor (Trade commands -> for Stations) command section.Fnord Lightbringer wrote:This works well, but there does not appear to be an "add secondary resource to factory". Hrm.
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!
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!
-
- Posts: 57
- Joined: Sun, 25. Dec 11, 16:04
Ah, persistence wins the day!
Here's code that works:
Here's code that works:
Code: Select all
$Wares = $Factory-> get tradeable ware array from station
$Counter3 = size of array $Wares
while $Counter3
dec $Counter3
$Ware = $Wares[$Counter3]
if $Factory-> uses ware $Ware as product
$NewStation-> add product to factory or dock: $Ware
else if $Factory-> uses ware $Ware as primary resource
$NewStation-> add primary resource to factory: $Ware
else if $Factory-> uses ware $Ware as secondary resource
$NewStation-> add second resource to factory: $Ware
end
$Amount = $Factory-> get true amount of ware $Ware in cargo bay
= $NewStation-> add $Amount units of $Ware
end
-
- Posts: 57
- Joined: Sun, 25. Dec 11, 16:04
Due to some kind of mod bug, I have a few shipyards that are broken in my universe. I have played for a while now, so I'd like to fix this without having to restart.
Basically I have a bunch of Argon shipyards that sell Water. That's it. No ships, no stations, just water.
I tried "add default wares to station" but that did not do anything.
When I create a new argon shipyard with the cheat script, it has no ships and stations. I could add them all manually, of course, but the super shipyard in Cloudbase Southeast is OK, so I figured I could just copy the ships and stations from there. Is there an easy way to do that?
Thanks!
Basically I have a bunch of Argon shipyards that sell Water. That's it. No ships, no stations, just water.
I tried "add default wares to station" but that did not do anything.
When I create a new argon shipyard with the cheat script, it has no ships and stations. I could add them all manually, of course, but the super shipyard in Cloudbase Southeast is OK, so I figured I could just copy the ships and stations from there. Is there an easy way to do that?
Thanks!
the Problem with Shipyards is that they have no default Products in most cases - they vary depending on Region (different Variants of the same Ship, technically different Ships) and therefore there are no Products defined for the Station type (with a few exceptions)
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
- X2-Illuminatus
- Moderator (Deutsch)
- Posts: 24962
- Joined: Sun, 2. Apr 06, 16:38
In the Trade Commands for stations, there's a command called "get tradeable ware array from station" which should return all the ships and stations the shipyard sells. You can loop through that array and add all ships and stations one by one. Just keep in mind that it's not enough to just add the ship/station type to the shipyard (using the "add product to factory or dock" command). You also have to add 1 unit of the type to the shipyard (using the "add ware" command). Otherwise the stock will be empty.Fnord Lightbringer wrote:so I figured I could just copy the ships and stations from there. Is there an easy way to do that?
The downside of creating a shipyard via script is that it doesn't establish a connection to the sector's Equipment dock iirc, which complicates equipping ships after buying them. What you could try though is destroying the shipyard and letting the game rebuild it. (Provided it's placed within the map file at all.)
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!
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!