Ship Factory (and ST Factory)

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

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

Post Reply
rainbowman
Posts: 26
Joined: Sat, 21. Jun 08, 14:31

Ship Factory (and ST Factory)

Post by rainbowman » Sat, 23. May 09, 01:26

NB update 24 September 2009 - the website below is no longer available and I am trying to find a new home for storing. If anyone has already downloaded can you share it around, please.

Ship factory that produces ships.
St factory that produces station kits.

(files recompressed and uploaded again on 1 June 2009)

Shadowdancer v2 Zip file

Shadowdancer v2 RAR file

Shadowdancer v1 Zip file

Shadowdancer v1 RAR file

***WARNING***
As noted in the Readme, loading ships as a cargo item into the cargobay of one of your ships will crash the game, so please do NOT do it. (Particularly - don't complain to me after I have just warned you...) The ships are actually sitting in the docking bay of your factory, or floating near the station on the sector map.

1. Does the script package download properly?
2. Does it create conflicts?
3. Does it work at all?
4. Is the price of 188 million too high? Should I adjust so that has lower price, but requires the TL to carry spare parts (consumed) to build the assorted factories?

I was hoping to have slightly more completed. But have decided to present what I have, while I struggle to get the other bits working...

I have enclosed the AS-BuyRareGoods scripts - also available separately from the Xai Corporation site - but haven't had the chance to thoroughly test them out.

(Extract from the Readme)
Four new items are used for this package - "Construction Licence" & "Naval Engineers Licence" for the Playership, and, the "Whirlwind" assembly kit and the "Shadowdancer" assembly kit to be fitted to a TL sized ship - either a TL or a modded big ship that can carry ST-sized. A freighter can buy the assembly kits at selected Equipment Docks, then use Freight Transfer once docked within the TL. The Whirlwind allows building of ST Factories, while both are required to build Ship Factories. You can build as many as you want, but will need to provide res and a blueprint for each. The Shadowdancer will only be available if you have a Police Licence for the Race that owns the sector in which the Equipment Dock exists. The prices are currently 17 million for the whirlwind and 188 million for the Shadowdancer. (Prices are subject to review, but future adjustments will consider profit to repayment ratios.)

Your TL will have Custom menus in the Command Console for "Build Support Factories" - Engine Components, Tel Paneling, Construction Equipment, and Weapon Interface Chips - plus "Build ST Factory" and "Build Ship Factory". All of your Big Ships including this TL should have "Park near a factory". (As these ships can't normally Dock at a factory - it is too small.)

Once you have built an ST Factory, any TL that is carrying a Station kit as cargo and that is within 3999m of the ST Factory will have additional option of "Use the ST package in cargo as blueprint" in the Custom part of the ships's Command Console. The St package is consumed in the process, but that item will now be a Product at that station, instead.

Once you have built a Ship Factory, any docked ship at that factory and any Big Ship within range of that factory (2000 for M6 and 3999 for other Capitals) will have option of "Use this ship as blueprint" (Custom/Command Console). The ship will be removed, so strip it of any gear that you want to keep... Docked ships will also gain option of "assignment Warehouse". Any ship sent for Reverse Engineering will attempt to offload its cargo to any warehouseship at that station. Also, be careful, as your TL-sized ships, may have either of these 3 options (blueprint ship, blueprint cargo, or assign warehouse) depending on where they are parked.

Neither of the factories will produce anything until you provide a blueprint. This consumes the item. Your factory will then have the primary res requirements assigned to it, based on the item itself, and will check res available just like a normal factory. If sufficient res, it will then cycle to produce your first product stock item.

Set the Command Console option (in the factory) to "Ship Factory ON" or "ST Factory ON". You then have the option of choosing a Race Food type (eg Cahoonas, Nostrop, etc), by inputting 1,2,3, etc. Choosing "0" (zero) will leave the factory without this Race food type. The "Ship Factory ON" is required to ensure that virtual stock of Shiptype is converted into actual ships. These ships are docked in your docking bay (Landed/Owned), or floating in space near your factory. The "ST Factory ON" doesn't make much difference at this point, as it is primarily designed for completeness and to allow compatibility with the MultiProduct system still in development. (Your ST packages don't need the Virtual to Real conversion.)

Ships will initially be "UnderConstruction" then "ForSale" (where they count as Stock). If the stock value has reached the Maximum storage, then the code will start transferring ships to "Guard", to make space for further production. (This will eventually be tied into an AutoFunctions command. I am still working on this system, and was hoping to have it completed, so that I could remove that section of code.) You can use the Guard ships. If you claim the ForSale ships then the stock value will be adjusted.

TL within range of your ST Factory will gain the "LoadST into cargo" (Custom/Command Console) once the factory has produced some stock...

Recommend that the ST Factory be used for stations that you will use a lot of, eg Solar Power Plants (circa 58mins). Ships can be produced in as little as 8mins for Discos, 12 mins for Harriers, M3s in roughly 3 hrs, upto capital ships which are in the range of days (Raptors at 16 days for example).

Edit 1/6/09

Have now completed a basic version of the autofunctions - allowing you to Move ships to a carrier or station, etc. Also your St are transferred to the warehouse assigned to that station. The other options will be available as soon as i am satisfied that they are working.

The restarts have now been installed with global variables, etc. (lol). So recommend that you empty your stock of ships to zero (rename them or move them completely out). The stock control is still having nervous twitches and sometimes refuses to keep the stock after creating it (after waiting for a couple of hours it tends to be a little annoying). Seems to work best if you start the command console, when the stock is actually zero, so that everything tallies. Save your position and then you can more cleanly overwrite the old version of the ship factory. (It should then be compatible with all future versions.)

I have combined the original setups into 1 file (the Shadowdancer setup) so the old ones can be deleted. You also need the Autofunc and the Sentinel setups, but these will eventually be combined into a single setup.

I am now going to check the comments at the end of this thread (made in my extended absence). Then I am going to consume some alcohol and get a break from the computer for a while. (Discos only take 6 mins but you get 50 of them - for a grand total of 5 1/2hrs. Testing is very long winded, and i am trying to multitask. lol) Seeya later.
Last edited by rainbowman on Thu, 24. Sep 09, 05:56, edited 10 times in total.

User avatar
Lord Dakier
Posts: 3243
Joined: Fri, 8. Dec 06, 13:45
x4

Post by Lord Dakier » Sat, 23. May 09, 02:47

Good to see this up... my cousin took his gfx card back the otherday so untill I get my under construction Death Star like computer up and running I cant play :(

User avatar
Chris Gi
Posts: 960
Joined: Wed, 20. Sep 06, 09:57
x3tc

Post by Chris Gi » Sat, 23. May 09, 10:01

I haven't tested it yet. Thus just a few pre-install remarks:

You should include the descriptions from the ReadMe in your first post. I hardly had any idea what this script package is doing (well, from your other posts I knew what it should do, but other people might not have this information).

You should also rename your zip- and rar-files to something more descriptive than "package1" :D .

Zip-Download works smooth, but rar doesn't work at all....

Now some scripting advice:
My personal liking is to use as little setup scripts as possible and to make them as fast as possible. They are run everytime you start a game or load a save game. Thus, a loop over the universe doesn't belong in a setup script. Make it a separate script and call it from the setup script.

Your global variables are not working. For example (from setup.shipfactory.xml):

Code: Select all

$ScriptVersion = get global variable: name=$shipfactoryversion
[...]
set global variable: name=$shipfactoryversion value=$ScriptVersionCurrent
The variable $shipfactoryversion is not initialised, thus it's value is NULL. You are storing the script version in a global variable named "NULL". The same is true of the other setup scripts. Thus, other scripts override the content of the variable "NULL".
Just assign a value to $shipfactoryversion like "rainbowman.ship.factory.version" and everything should be okay. I guess that's why you get the impression that only 1 variable is allowed.

To get the Khaak ship data: just enable the in-game Galaxy Editor. If you start the GE, all data is available to you. This is may favourite way to code Khaak stuff, because there are no more "Unknown enemy ship" or "Unknown object".
--------------------------------

[ external image ]

Jonson27
Posts: 170
Joined: Thu, 3. Jun 04, 14:08
x2

Post by Jonson27 » Sat, 23. May 09, 11:01

Chris Gi wrote:Now some scripting advice:
My personal liking is to use as little setup scripts as possible and to make them as fast as possible. They are run everytime you start a game or load a save game. Thus, a loop over the universe doesn't belong in a setup script. Make it a separate script and call it from the setup script.
What exactly do you mean? Do you mean "START NULL->" in the setup script? Where would the universe loop be? Presently, I have a universe loop in a setup script. That's why I ask.

While the load-game pause is several seconds... it's bareable. However, the universe loop is simple and there's not much processing associated with it.
Hello there!! (Jumping up and down)

User avatar
Chris Gi
Posts: 960
Joined: Wed, 20. Sep 06, 09:57
x3tc

Post by Chris Gi » Sat, 23. May 09, 11:46

Do you mean "START NULL->" in the setup script?
Right.
Well, like I said: it's "my personal liking". It's nothing wrong with it unless you do some performance intensive things. But why do you loop over the whole universe: to install a ware to some station or some similar task. It's not necessary to have this ware immediately in a sector 20 jumps away. I prefer faster loading of the game instead immediately availability of a ware in the whole universe. By moving the loops to a non-setup script, you can set the waits to a greater value and thus minimizing the effect of the loop script.
--------------------------------

[ external image ]

rainbowman
Posts: 26
Joined: Sat, 21. Jun 08, 14:31

Post by rainbowman » Sat, 23. May 09, 13:45

I can create a setup that calls the Item distribution loop, in the same way as I did the Sentinel. Also, all of the setups will eventually be in a single file, but with separate selects for each command console instruction.

Thanks for your help. I will have another play with locals/globals - getting them to work would make things easier. :lol:
The problem I had was that i would set the factory with factorytype 2 which works fine for identifying nearest station, then find that another local variable (with a different variable name) for the same station would overwrite the factorytype with its value, which then confused other comparison tests.

so will i be able to use restart scripts, if i used the following?

set global variable name= shipfactoryversion value= -1
scriptversion=get global variable name=shipfactoryversion
[...]
set global variable name= shipfactoryversion value= scriptversioncurrent

For other players, would the "Unknown Enemy Ships" tag still appear in their scripts, but in a manner similar to the Readtexts, where the code can still recognise it. When you go into the ship listing, you can see the pictures of the different ships, but they are all called "Unknown...". So I was trying to make it fit with my comparison tests.

Most people can handle zips, so I will probably remove the RAR version. I had to go hunting around to find the WinRar, in order to extract other downloads. Windows has a built-in zip extractor, doesn't it?

User avatar
Chris Gi
Posts: 960
Joined: Wed, 20. Sep 06, 09:57
x3tc

Post by Chris Gi » Sat, 23. May 09, 15:15

Well, to use multiple global (or local) variables, you need to give them unique names. You need to do something like this:

Code: Select all

$name = 'a.global.var'
set global variable name= $name value= 1
You can now use another global version when you assign a different name:

Code: Select all

$name = 'another.global.var'
set global variable name= $name value= 2
If you retrieve the global vars, just pass the respective names and you get:

Code: Select all

Global var 'a.global.var' is 1.
Global var 'another.global.var' is 2.
For other players, would the "Unknown Enemy Ships" tag still appear in their scripts
The name of these ships is handled internally by the game engine. Whether the player sees "Unknown Enemy Ship" or "Khaak Bomber" depends on the Khaak data stuff. You don't need to bother.
That's why I tend to write scripts dealing with Khaak ships in Galaxy Editor mode. The ship type I'm using is "Khaak Bomber", and I know exactly if I use the right ship without trying to figure it out by those little pictures.
If I reload the script in the Script Editor in normal game mode, without the Khaak Data already available, I see the same script with "Unknown Enemy Ship".
--------------------------------

[ external image ]

rainbowman
Posts: 26
Joined: Sat, 21. Jun 08, 14:31

Post by rainbowman » Sat, 23. May 09, 16:00

(I have updated the first post.)

I think it is the speech marks bit that i am leaving out... But without loading up, i can't remember. I am using unique names, though. I'll check tham next time i get into x2.

What happens with the Rar file? Does it not load at all? Should I remove it to leave space for the gazillions of zips yet to be coded... :wink:

So it should work if i have 6/7 different tests for each of the "Unknowns.." The player only sees "unknown enemy ship" but the game has a hidden flag iding it as a bomber, scout, interceptor, etc. Right. I'll sort that out later.

Jonson27 -
You can write your setups as calls to other programs eg.
global=null
start global call script universe.loop

I tried doing a start global to kill the ship after reverse engineering it. However, it kept freezing the game. So i have set the instruction elsewhere... (subtask.disassemble)

User avatar
Chris Gi
Posts: 960
Joined: Wed, 20. Sep 06, 09:57
x3tc

Post by Chris Gi » Sat, 23. May 09, 17:16

You have a typo in the rar-url. It's "x2_downloads", not "x2-downloads".
I am using unique names, though. I'll check tham next time i get into x2.
Well, not in the script package I downloaded. For example, the first lines of the script "setup.shipfactory" read:

Code: Select all

001   $ScriptEngineVersion = script engine version
002   skip if $ScriptEngineVersion >= 25
003    return null
004   $ScriptVersionCurrent = get script version
005   $ScriptVersion = get global variable: name=$shipfactoryversion
Take note of the variable $shipfactoryversion. This variable is uninitialised, having a value of "NULL". Thus, you try to read from a global variable named "NULL", not "shipfactoryversion". The line should be:

Code: Select all

005   $ScriptVersion = get global variable: name='shipfactoryversion'
So it should work if i have 6/7 different tests for each of the "Unknowns.." The player only sees "unknown enemy ship" but the game has a hidden flag iding it as a bomber, scout, interceptor, etc. Right. I'll sort that out later.
Right, but it's not a flag. Actually, scripts refer to something like "objects", in this case a ship with certain properties. One of these properties is its name. It's the name you see in the script editor, but you're referencing an object, not the name. The name of a ship can be changed, it can even be changed by scripts. It doesn't matter, because it's a property, not the thing itself. It's the thing itself you're refering to in scripts.
--------------------------------

[ external image ]

rainbowman
Posts: 26
Joined: Sat, 21. Jun 08, 14:31

Post by rainbowman » Sat, 23. May 09, 17:35

I think it is the missing speech marks that is causing the problem. All of the different files are using a different "version" name but without being inside a set of speech marks, so they won't be recognised as being different from the Null. I can sort it out for version 2. It isn't a priority until i get a restart system into operation. The only bit that is vital at the moment is the factorytype, else the command consoles start going wonky...

User avatar
Chris Gi
Posts: 960
Joined: Wed, 20. Sep 06, 09:57
x3tc

Post by Chris Gi » Sat, 23. May 09, 18:05

"Missing speech marks"? What do you mean by that?
What I was trying to say is that the scripts are NOT using different "version" names. Your variables aren't initialized. You need to assign a value to variables like $stprefabversion and $shipfactoryversion.

You either have to include lines like the following into your code:

$shipfactoryversion = 'shipfactoryversion'

or use a string in the set global/get global instructions:

$ScriptVersion = get global variable: name='shipfactoryversion'

I hope it's clearer now...
--------------------------------

[ external image ]

rainbowman
Posts: 26
Joined: Sat, 21. Jun 08, 14:31

Post by rainbowman » Mon, 25. May 09, 13:37

I recognised my error about 3 postings above... Filling my thread with constant references is unnecessary. Thank you for helping me to recognise the error.

The local and global variables are assigned by using string rather than variable. Hence their names are placed inside a single set of speech marks.

Has anyone run the scripts? I need to know if the package causes conflicts. I am making a bit of headway with the Autofunctions, so I should be able to include those additional scripts in version 2. The Multiproduct system should be completed for version 3.

Jonson27
Posts: 170
Joined: Thu, 3. Jun 04, 14:08
x2

Post by Jonson27 » Mon, 25. May 09, 20:45

Chris Gi wrote:
Do you mean "START NULL->" in the setup script?
Right.
Well, like I said: it's "my personal liking". It's nothing wrong with it unless you do some performance intensive things. But why do you loop over the whole universe: to install a ware to some station or some similar task. It's not necessary to have this ware immediately in a sector 20 jumps away. I prefer faster loading of the game instead immediately availability of a ware in the whole universe. By moving the loops to a non-setup script, you can set the waits to a greater value and thus minimizing the effect of the loop script.
Yer probably right. One way for me to nail this down is just to send myself a message when it's complete. I bet it'd be almost immediately :) That was my original reason for not having any wait(s); to make sure it's all done b4 the game even starts. But is that really needed as you say?

Whne should init be used? I've stayed away from init becaus I think I read that it's only run once... when you start a new game. And I don't like that because then you couldn't run the mod in a saved game. However, there're cases you wouldn't want a mod to run on a saved game that didn't have the mod from the start. It's just my preference, atm.
Hello there!! (Jumping up and down)

rainbowman
Posts: 26
Joined: Sat, 21. Jun 08, 14:31

Post by rainbowman » Mon, 1. Jun 09, 02:34

Inits are run before some of the items you will need, so it was causing crashes for other people. (In the same way as doing something to the playership needs to check that it actually exists. There are other items similar in this regard) I am having to convert/rename a lot of the older scripts, as they were mostly using Inits.

If you use the Start option, then it should run it as a separate process, and thus shortens the wait before loading has completed. You will need to assign a variable to "null" though as the "null" isn't offered as an input option for the call script. (Variables are available though.)

If you don't put waits into your complicated loops (particularly the while..end version), then you are very likely to get "hang-time" - think of having a lot of entries in your logbook and how long it takes to load up. Also, watch the game - all the animations stop while it is dealing with your script. The waits allow the multitasking system built into the game to function. Hence, everything appears to be moving at the same time. If you hog the processor, everything stops. Straightforward step by step instructions should be okay without any waits - it will just zip through the lot of them. I usually put a wait just between my loops, rather than inside them, but the principle is pretty similar.

User avatar
Lord Dakier
Posts: 3243
Joined: Fri, 8. Dec 06, 13:45
x4

Post by Lord Dakier » Mon, 1. Jun 09, 17:47

Will this run automatically cause get like one thousand scripts in my editor lol.

rainbowman
Posts: 26
Joined: Sat, 21. Jun 08, 14:31

Post by rainbowman » Tue, 2. Jun 09, 05:50

Hiya

My package (version 2) has only 3 setups now. They should be running automatically. Unfortunately, I have just noticed that the setup for the AS Buy Rare Goods is actually an INIT. (My version in scripts was converted.) So those who wish to use the Buy Rare Goods will have to copy, rename and then delete the old Init version. I will include the setup version in my next version of this script package.

My previous post was in answer to Jonson27's post. Chris has also answered - but on another thread.

Currently busy trying to get a reverse version of the Auto Money to Player Account, to supply the factories with some dollars. How long do you think it takes to collect 90million in res... and they need the money to start with. Was getting a little tired of having to feed them. lol

How are you getting on with your Mega Missile Barrage of Death project?

:wink:

User avatar
Lord Dakier
Posts: 3243
Joined: Fri, 8. Dec 06, 13:45
x4

Post by Lord Dakier » Tue, 2. Jun 09, 14:32

Im not getting on at all lol. I cant play X2 at the moment cause I have no graphic card lol so unless Chris Gi would like to finish it off... not that I really started it much in the first place :P

Im just looking for a job and continuing my Rome Total War mod for a bit.

Hitty40
Posts: 3
Joined: Sun, 17. Feb 13, 20:10
x4

Post by Hitty40 » Thu, 6. Jun 13, 04:52

Does anyone have a copy of the files I can download?

Post Reply

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