[MOD] Complex Cleaner v4.09 / Modular Complexes (TC 3.2 / AP 1.1)

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

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

Post Reply
Posts: 11
Joined: Thu, 17. Apr 08, 00:57

Post by biliskner25 » Wed, 3. May 17, 15:55

Grape wrote: I do dream that at some point this mod will be revisited and the calculations for Mine output get a going over - ah well :)
Although a very old post, I have actually done just this :wink:

I haven't been able to figure out what numbers Gazz used to come up with the formula for calculating mine sizes but I realised that the numbers used actually killed about 11% of silicon before even crunching. That means a L mine on a 40 yield, technically equal to a Fact 5 would always yield 2 x Fact 2.

Changing the calculations to be based off a 40 yield asteroid for ore and silicon fixed it nicely, you will still lose anything less than a size S station but you shouldn't lose it from calculation errors.

Edit: also adjusted Tfactories

Posts: 465
Joined: Tue, 15. Aug 06, 13:36

Post by bounty_hunter66 » Sat, 13. May 17, 06:46

Does this work for AP 3.2?

Posts: 5
Joined: Sat, 24. Feb 07, 08:59

Post by XIII8 » Fri, 14. Jul 17, 03:42

So, first of all note this: I got no frikkin clue about modding in X3, and this is my first and only attempt at doing something. If it corrupts your saves, blows your PC or tommorow you get a visit from stalin, mao and hitler, don't blame me!

If what I'm sharing isn't allowed, or I did it incorrectly, or the modder doesn't wish me to do that, please tell and it's gone.


Anyway, it annoyed me that this mod technically worked, but caused a whole load of issues. Bunch of factories like spectre/mam-ammo factories were missing in shipyards, no prototype mam factories in aldrin, that kind of stuff. The placeholder factories in yards were kinda annoying too.

It's not that the mod just overrode old factories, the tfactories list itself was just completely outdated and missed a whole bunch of stuff. Either there was some massive expansion of the T-list in 1.1, or it was just taken from TC. I imagine the former, considering we're talking about an experienced modder here.

So I think I fixed it. Tested it for a few hours and everything seemed fixed, products were back, and shipyard catalogues fine again. Basically, I grabbed the tfactories from Albion Prelude and compared it too the CC one. Now the vanilla file ends at number 455, and my CC file started at 456. So I basically just grabbed the vanilla list, copied the CC entries into it, and packaged it into the CC cat.

I thought I might share it as well; just make sure to create a copy of your save folder beforehand. If you don't know where to find them, check PCG wiki. Also, replacing that file will remove the complex center, you'll still keep the FACT's and their ressources though. If they start crashing against each other, make a crunch order one or two time while being in sector.

EDIT:Fixed a small visual bug, complex boxes were invisible. Incorrect numbering.
https://www.file-upload.net/download-12 ... 2.zip.html

Posts: 3
Joined: Tue, 24. Oct 17, 11:36

Post by HongoBLAST » Tue, 24. Oct 17, 11:55

SirNukes wrote:I too ran into the overproducing 1x factory bug. After some digging into X3 modding, I narrowed down the problem. My apologies if someone already revealed this earlier in the thread; I only read the last few pages. In short, the Tfactories file in this mod needs updating/debugging for the current version of AP.

Interestingly, the two downloads in the top post (Zip for manual install, and the packed version for plugin manager) have different versions of Tfactories, and both are problematic in different ways. The 'manual install' version appears to have just copied the TC version of Tfactories into the AP addon folder, and does not have the new AP Terran factories. The plugin manager version, which I was using and experienced the 1x bug with, was updated for the newer AP factories but has a mistake.

Specifically, CC for TC inserts its template modules (1x to 200x) on lines 455-464 of Tfactories, following a series of placeholder entries on lines 440-454 to act as a buffer against changes. The current AP base Tfactories includes entries all the way up to 455. In the plugin manager download of CC, the new AP factories appears to have just been pasted over top of the TC version of Tfactories. However, there wasn't enough buffer space to support this, and the smallest CC module (1x) on line 455 was overwritten with a Terran large ice mine.

Whenever CC crunches factories and tries to add a new 1x module, it actually uses the large (5x) ice mine as the template, creating an overproducing module. You can see evidence of this in the naming of the 1x factories in game, which use MI (mine) where the the other CC modules use TE (tech). To complicate matters further, the faulty 1x factories are treated as 5x for subsequently generating larger modules; for example, three Medium factories will get crunched into one 5x and one faulty 1x, which get immediately re-crunched into one 10x.

If you are using a mod which changes Tfactories, incorporates the CC modules, and is up to date for AP, then you probably aren't seeing this bug. Otherwise, you will need to fix the Tfactories file and update your savegame. After some hours sorting things out, here is the procedure I ended up using on my game:

1. (Optional) Back up your savegame.

2. (Optional) Start AP, load the save. CC will end up deleting your hubs connected to CC modules and then recrunching automatically, so in systems that have module containers you will want to set Ignore on the factories you want to leave untouched. If such a factory is already connected to a hub with other crunched modules, you may need to self-destruct the hub to be able to select the factory to ignore. For example, if you have a crunched complex to which you added un-crunched mines (for aesthetic or practical reasons), you need to break the hub and set ignore on the mines, otherwise they will get auto-crunched later. To set ignore, you have to travel to the system, target the factory, and use the ignore command (the popup selection prompt appears to do nothing).

3. Resave and quit AP.

4. Extract Tfactrories.pck found in 03.cat in the addon/types folder using X3 Editor 2 or some similar program, to obtain a ~458 line text file (the editor may add a couple comment lines). You can see that its last line is for the Terran large ice mine, SS_FAC_TR_ICE_PL_1.

2. Open the Tfactories in the CC cat file with the text viewer, scroll to the bottom, copy the ~38 lines for the CC modules and placeholders (they all have GAZZ in their name), and paste them to the bottom of the Tfactories from step 1. For the plugin manager version, use Tfactories from /types and not addon/types, since the latter is missing CC factory entries. For the manual install version, Tfactories from either .cat should work.

3. At the top of your Tfactories, adjust the number of factories appropriately (eg. from 455 to 493), as described in the top post of this thread.

4. Save your new Tfactories back into the CC .cat file into addon/types, compressing it back into a .pck file.

5. Open setup.plugin.gz.CmpClean.xml in your addon/scripts folder using a text editor, scroll down to line 339, and change the version number from 409 to 410. This is required to trigger an in-game update, which will load in your fixed Tfactories correctly to the CC data tables stored in your save game. After conversion, you can change the version back to 409 if you like.

5. Load up AP and your save game and wait.

What to expect:

After a few seconds, a message should popup indicating CC was installed/updated successfully. This message will include the last line number in Tfactories where a CC module was found. Before the changes, this line was ~477. After changes, the line should be ~492.

Some seconds later, a series of crunch reports will appear for your systems with CC modules. The hubs attached to these modules will be gone. Resources that were in the hubs are distributed across the modules, money in the hubs is returned to the player account, and docked ships should have been undocked. Unfortunately, you will need to reconnect the modules and set your complexes back up.

Existing faulty 1x modules (produced at 5x) will have been replaced with the fixed 1x modules (produce at 1x). You may also notice that the 1x factories now use TE in the name instead of MI.

This will not fix any larger modules that were the result of crunching the faulty 1x factories, such at the three mediums to 10x example from earlier. However, any crunches on the new, fixed 1x factories should work correctly.

I know this thread is getting a little older, but hopefully those still playing will find this post helpful. Except for the bug, I love this mod.
I had the same problem and although you explained it in a great way it cost me to make it work due to my lack of experience, but in the end I succeed!

In case someone has the same problem I uploaded the files with the corresponding fixes that you described previously: No more Ice Mine!

Posts: 5
Joined: Wed, 23. Jul 14, 21:25

Post by ztd74 » Sun, 21. Jan 18, 07:14


Hi. I use AP + XRM with complex cleaner. So where do I have to copy your .cat/.dat files? I replace the original Complex Cleaner .cat/.dat or add after them? In TC folder or AP (addon) folder? As lower numbers or higher numbers than the XRM ones? Please states it clearly. Thanks for helping sort this out.

For HongoBLAST

Hi. Again I use AP + XRM with complex cleaner. So where do I have to copy the files in your .zip? extract directly into addon (AP) folder maintaining directory structure (I mean same files in same directories overwriting existing versions)? What about original .cat/.dat files? Thanks you too for the help.[b][/b]

Posts: 3
Joined: Tue, 24. Oct 17, 11:36

Post by HongoBLAST » Tue, 23. Jan 18, 11:11

ztd74 wrote:So where do I have to copy the files in your .zip? extract directly into addon (AP) folder maintaining directory structure (I mean same files in same directories overwriting existing versions)?
Yes, first install the mod and then overwrite the files with the one's in the zip. It is only a minor tweak.

Posts: 5
Joined: Wed, 23. Jul 14, 21:25

Post by ztd74 » Tue, 23. Jan 18, 22:45

Hi. Thanks man. One last question: you think script and t files you modified will work also with .cat/.dat from XIII8? Sorry for the dumb question, but I'm not very smart on programming...anyway thanks a lot for your help.

update: sorry for bothering, but I fear your fix is not compatible with XRM: using your edited Tfactories.txt file I got some strange stations name changes (eg "PAR shipyard" changed into "Container Module 2", for some other I got <invalid> as name)...

update II: I'm definetly dumb: XRM already fixed this bug in Tfactory file contained into its .cat/.dat

Posts: 3
Joined: Tue, 24. Oct 17, 11:36

Post by HongoBLAST » Thu, 25. Jan 18, 22:07

ztd74 wrote:Hi. Thanks man. One last question: you think script and t files you modified will work also with .cat/.dat from XIII8? Sorry for the dumb question, but I'm not very smart on programming...anyway thanks a lot for your help.
If XIII8 modify the Tfactory then no, you will have to edit it to add all the entries. The post of SirNukes above says how to do it.
ztd74 wrote:XRM already fixed this bug in Tfactory file contained into its .cat/.dat
That's great! :D

Posts: 15
Joined: Tue, 13. May 14, 10:33

Post by century » Wed, 28. Mar 18, 20:10

DrBullwinkle wrote:Here is Complex Cleaner repacked for easy installation with the Plugin Manager. Works for both TC and AP. The PM will automatically renumber and install the fake patch into the correct folder.

Complex Cleaner 4.09 Repacked for Plugin Manager for TC and AP 3.x

Complex Cleaner 4.09 for Major Mods (XRM) (This package includes models but not TFactories, so can be installed safely. It will not cause a conflict)

Old Version: Complex Cleaner 4.09 Repacked for Plugin Manager for TC and AP 1.1-2.5.x

Instructions for vanilla TFactories
Install with Plugin Manager (click the Install Archive button).

Instructions for major mods (XRM, etc)
If using a major mod such as XRM (that already has the Complex Cleaner modules in TFactories), then do a manual installation. Install .cat/.dat pair as a fake patch at a lower number than your mod's fake patch.

Edit [1st Dec 2015]: replaced outdated with working xdownloads link. X2-Illuminatus

hi there

i ran into problems between Complex Cleaner MOD and MobileRepair MOD

after many searches , i used your version and see it in depth
i noticed a glitch (?) , about the Tfactories.pck , about a missnamed one
it have an invalid string in Boron Drone factory

so it appears in the game misnamed , and this was not here in the precedent CC MOD package

just to let you know, it's no big deal

when i get back in game some (not all) of my complexe where blowed so no more HUB but still the modular complex

i had to re link with complex kits but didn't loose what they had already produced :P

Happy and still rich :)

just my 2 cents

PS : sorry for my english :oops:

PS2 : btw i play XTC 3.2 (to let you know) and some scripts

Posts: 1
Joined: Fri, 30. Mar 18, 08:15

Post by TheVillain » Mon, 16. Apr 18, 17:06

So if your trying to get Complex cleaner to work for Litcubes universe - but are having all kinds of fun having to run the script via the script editor:

  • Go into the script "setup.plugin.gz.CmpClean" and line 24:
  • set script command upgrade: command=725_COMPLEX_CLEANER upgrade=Tractor Beam
(note that it wont say "TractorBeam" in Litcubes Universe if your doing this after install because it has been totally removed from the game. It'll be blank).

Change that last bit to anything else that is a ware (I went with Special Command Software). Can be done either before installation (not tested but should work?) or after install via the in game script editor.

Posts: 103
Joined: Fri, 22. Apr 16, 21:25

Post by Ramokthan » Thu, 30. Aug 18, 02:16

I wonder why "drop" doesnt work anymore.

Or do i miss something. I just started a new game after some years, still had the mods etc saved and i know the drop command worked once.

No use to place all factoried by hand and see these painful videos.

I got a TL with some Factories in it, which has Tractor Beam installed.

I found it. You should use the commands accordingly to your CC language version, AKA u have to use DROP on the english version but BAU on the german version. I feel kinda stupid now. However the command "BAU" is not offered in the menue anyway where you are supposed to use it.

akari no ryu
Posts: 128
Joined: Sun, 11. Oct 09, 14:32

Re: [MOD] Complex Cleaner v4.09 / Modular Complexes (TC 3.2 / AP 1.1)

Post by akari no ryu » Thu, 31. Jan 19, 00:11

So I'm having the old "Ice packing facility" appears when you try to create a complex. Is there a fix for this available?

It's a vanilla install of X3AP other than Mod Complex Cleaner 4.09 which is installed using the Mod Manger from the google code dump

Edit: Found the 4.1 fix above, but the "hub" command is still not working. The autopilot engages and then disengages and there's still no hub.
Further edit: Never mind. I remember how it works now. You connect two stations with complex tubes and the hub appears.

User avatar
Posts: 384
Joined: Sun, 8. Jan 06, 19:43


Post by Khaakbuster » Sat, 5. Oct 19, 02:39

X3:3X wrote:
Wed, 9. May 12, 00:56
I have X3tc Xtended installed and no other mods aside from this one and MARS

Ok, so i threw together some complex designs in Xadrians to test this out before i got a feel for the mod, the currently testing is just a simple fight drone complex with,

2x Chelt Space Aquarium L
2x Split Crystal Fab L
3x Argon Drone factories
1x Massom Mill L
3x Rastar Refinery L
1x Scruffin Farm L
1x Split SPP L

They will not crunch, i get the message;
No crunchable factory types found in sector Uncharted Sector
I can not work with factories that are part of a complex
That would destrpy the complex
I know I'm late for the party but I have just started another round of X3TC with X-Tended 2.2a and decided to try the Complex Cleaner 4.09. I've been pulling my hair out to get this to work properly.

Whoever is still interested in getting Complex Cleaner to run with X-Tended 2.x may find this useful:
  • 1. If you have X-Tended 2.0 or higher you do NOT need the CAT/DAT from the Complex Cleaner or do a manual merge. The CC modules are already incorporated in X-Tended. Use the CC scripts and T file only.
  • 2. If you want to use the "Drop" command of Complex Cleaner you have to modify plugin.gz.CmpClean.Main.xml or the Crunch command will not recognize your stations. The reason for that is that the Crunch script checks if X-Tended is running and if that is the case it checks if the station has a local variable "XTC.LOCAL.STATION.CONFIGURED" set. If this is missing the Crunch command will ignore this station. The problem is that XTC station initialization isn't done when we use the Drop command and therefore the variable doesn't exist. I'm surprised that this hasn't been fixed long ago.
You can download an updated plugin.gz.CmpClean.Main.xml here:
Link removed. Use link in below post that contains additional fixes.

Here are some boring technical details of what I changed in the script:

Code: Select all

*     Build stations:
$Stations.built = $Stations.built + $Ind.X
= $Ship-> add -99999999 units of $Ware
while $Ind.X
	dec $Ind.X
	gosub Find.Station.Pos:
	$Stations = create station: type=$Ware owner=[Player] addto=$Sector x=$New.X y=$New.Y z=$New.Z
	$Stations-> add default wares to station/dock
	$Stations-> factory production task: on=[TRUE]
	do if $XTC.enabled
		= $Null->call script 'plugin.XTC.Config.Station' : station=$Stations

	= wait 1 ms
The "do if $XTC.enabled" part with the function call had to be added so the station is initialized properly. If you deploy a station manually IS the "plugin.XTC.Config.Station" is called automatically but this would not happen before the fix when the Drop command of Complex Cleaner was used. I found it a bit tedious to drop hundreds of stations manually and watch the video sequence over and over so I decided to fix the Drop function instead.
Last edited by Khaakbuster on Sat, 19. Oct 19, 13:57, edited 1 time in total.

User avatar
Posts: 384
Joined: Sun, 8. Jan 06, 19:43

Re: [MOD] Complex Cleaner v4.09 / Modular Complexes (TC 3.2 / AP 1.1)

Post by Khaakbuster » Sat, 19. Oct 19, 13:54

I found another bug with Complex Cleaner in regard to X-Tended. It is not possible to crunch existing factory modules into larger factory modules because of a simple logic error in "plugin.gz.CmpClean.crunch.xml". If you have X-Tended running the Complex Cleaner refuses to recognize its own factory modules.

On top of that there is a bug in X-Tended 2.2a itself that makes customizable factories (e.g. weapon and shield fabs) incompatible with Complex Cleaner. As I have written before newly deployed factories get the local variable "XTC.LOCAL.STATION.CONFIGURED" set after being set up completely. This doesn't work for customizable fabs because of a logic error in "plugin.XTC.Config.Station.xml" or "plugin.XTC.Task.ChangeProducts.xml" respectively.
"plugin.XTC.Task.ChangeProducts.xml" creates a new fab with your choice of product and destroys the original fab so it's not very useful to try to set "XTC.LOCAL.STATION.CONFIGURED" on a fab that has just been blown up by the script...

I have put all three fixed scripts into an archive that you can download here. This will make CC 4.09 truly compatible with X-Tended 2.2a. At least I haven't noticed any functionality that doesn't work as advertised.

Posts: 1
Joined: Wed, 15. Jan 20, 15:03

Re: [MOD] Complex Cleaner v4.09 / Modular Complexes (TC 3.2 / AP 1.1)

Post by Geomagus » Fri, 17. Jan 20, 01:14

Sorry for the thread necromancy. I’m an utter noob with regards to the inner workings of mods, and need some help.

I’m trying to use this mod in conjunction with Star Wars Mod (Reborn), from https://www.moddb.com/mods/mikhail-skatchkov

I’m also using a bunch of smaller scripts and such, but I believe the problem is between these two, because of TFactories changes. And I am at my wits’ end. I tried reddit, and now I made an account here just to seek help.

At first I tried installing via Plugin Manager. I got the popup that said everything was correctly loaded, but it completely broke a bunch of Star Wars Mod factories (the ones at the bottom of the list).

Then I tried manually installing as a false patch. This time the pop up said text files detected, but station objects not detected.

I also tried installing as a false patch before the Star Wars Mod cat/dat files. I even got X3 Editor 2 so I could try merging the TFactories files together so that all the CC stations were added to the end (it was an adventure). Each of these had the same message as the initial false patch: successful text file installation, but station objects not found.

Is there a way to reconcile these two mods? There must be, right? I’m out of my depth, though, and in need of guidance. Help me, expert modders? You’re my only hope! (Please?)

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”