[SCRIPT] IFTSOS - Install Factory to Station or Ship

The place to discuss scripting and game modifications for X³: Reunion.

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

Lancefighter
Posts: 3144
Joined: Sun, 19. Dec 04, 02:41
x4

Post by Lancefighter »

Hmm. Perhaps somehow the commodity logistics script could be used.
Rhelok
Posts: 23
Joined: Sat, 5. May 07, 06:38
x3ap

Post by Rhelok »

Eight seconds for every 100 isn't so bad. I don't think I've ever had more than 10 TL's running around doing things. M1's that can actually carry factory class cargo seem to be few and far between. If ships got out of hand would it be viable to split the array in half and run them 30 seconds apart from each other? It's still a 60 second interval for each subgrouping.
MJALowe
Posts: 461
Joined: Fri, 5. Jan 07, 06:27
x3

Post by MJALowe »

let me re word the timeing...when i ran the timeing test i ran it on the script that fills the global array with the default data...(only runs once per game normally)...i ran it 1000 times and it took 80 seconds...(80ms per run)

the timed part of the script should actually run faster, but i had no real way to time it....didnt fancy creating 1000 pHQs and loading them all with a single factory - or one of each

edit: this was basically why in the orginal post i was asking for some scripters to look over the code and do some testing...

edit2: just did a major test of the TL/M1 stuff...i modded a TL to have an insanly huge cargo...put 20 different factories in it and all the goods it should need for 10 runs (edited the factories to run every 60 seconds for this test) then i used a clone ship script (dont remember which one...just had to make sure that all the cargo would be there and it was)...made 100 ships....no noticable performance impact...
note: im running a 3.4ghz p4 945d and a 8800gtx video...very doubtful to me that this test would be representative for other peoples performance...but 100 ship not even having a "skip" id say was pretty good

if you are using this script please post a reply with observed "lag" and "skips" that could be caused by this script, also any interface feed back is appreciated...even if i obviously dont want to do certain things (like have it use a command button) i will still read the feedback, and if i can figure a way to do it and stay within my current design rules i will do so
MJALowe
Posts: 461
Joined: Fri, 5. Jan 07, 06:27
x3

Post by MJALowe »

so, my next script task is gona be a script that runs in conjunction with this and has a TS/TP act as a supplier....this is gona take a long time for me to figure out how to do...
Heretic666
Posts: 463
Joined: Fri, 20. Feb 04, 17:30
x3tc

Post by Heretic666 »

MJALowe wrote:so, my next script task is gona be a script that runs in conjunction with this and has a TS/TP act as a supplier....this is gona take a long time for me to figure out how to do...
Nah thats easy ( :roll: )

But seriously, you could get an array of all products in the PHQ ($var1), then wait x mins and get the array again ($var2). Then go:

(For $curproduct) -dont know the wording off hand but you get the idea right?
If $var1 > $var2
Append $curproduct to array $prodarray
End

Then tell your freighters to get one of the products in the $prodarray

OK so I didn't write it so well, but the general idea is that if a product is counted ($var1) then x secs later is counted again ($var2) and is less, then chances are it's a resource. Then send out the freighters.

Obviously you'd have to check that $curproduct isn't a weapon/shield/missile/(other product that isn't used as a resource)

:)
Station Freight Transporter
B-O'F: Enjoy whatever you are doing, if you decide to try real scripting one day..
Dark-Venom
Posts: 45
Joined: Wed, 21. Dec 05, 22:59
x3

Post by Dark-Venom »

im completely lost at how i can get something like a Solar power plant to install to my TL using this script. so i have a mobile Power plant.

Can someone help me get this working?

i wouldnt mind having this on a M1 or TL, just to get it working ! :?
MJALowe
Posts: 461
Joined: Fri, 5. Jan 07, 06:27
x3

Post by MJALowe »

ok...to get a TL mobile power plant

a) install script (duh)
b) start a game...should be able to be a game in progess
c) enable the script editor if it isnt already *i think this essential even if you dont want to change it
d) open up the script editor and scroll down to al.iftsos.eventhandler
e) un comment line 28 (thats press the "," key while on line 28
f) save the script
g) put a solar power plant in the cargo of a TL and wait < 1 minute...you should get a message saying it was installed
h) there wont be an out of resources message, so to get it running be sure you have enough resources for it or it will just sit there
i) assuming you had the resouces when it runs the 1 minute mark it should "consume" said resources and at the 2 minute mark it should give you some e-cells



note: obviously this could result in a first minute super efficiency...but what they hey (this would assume you put it in the cargo at like the 50sec mark...

note2: the cycle time on power plants is 118 seconds, so every so often you will get "bonus" production...meaning at the one hour mark it will produce double (i think its the 1 hour) those 2 seconds arent lost every cycle, they are stored as a time bonus for the next cycle...get 60 seconds of time bonuses for a bonus production kinda thing...
MJALowe
Posts: 461
Joined: Fri, 5. Jan 07, 06:27
x3

Post by MJALowe »

@heretic

well, being that the station/ship will already have a list of all the factories installed that is updated every minute...
and being that i could use this to calculate how much is need and what the cycle times are...blah

because its so complicated what im gona do is this:

script runs on pHQ and effects homebased TP/TS/M6/M7

what ware do you want supplied
how much of ware do you want in pHQ cargo at all times
any other wares i should be aware of?

ofcoarse, i want to do this as a single command button (want it to be no buttons but that might be asking a bit much), and id really like to be able to remove ware...probably means i want an interactive message sent to the player...

anyways...i dont really know how to do any of that, the actual functionality of my script really really stretched my programing ability (orginally was gona do a two dimensional array but couldnt wrap my mind around it)

...its still gona take alot of effort on my part just to wrap my mind around the needed concepts and maths (i suck at math, well...not so bad...im up to precal but i still hate math)

someone want to do this for me? please please? my brains gona explode!
EdisenTreant
Posts: 7
Joined: Sat, 11. Feb 06, 21:49
x3

Post by EdisenTreant »

I hope this works as good as it sounds..
You can never get there...because you are always "Here"...
User avatar
Shovinus
Posts: 563
Joined: Sat, 9. Dec 06, 19:19
x3

Post by Shovinus »

MJALowe, would you mind if I have a look it to see if I can make it run faster? Or I can just suggest to you, rather than running the whole 300 everytime on the HQ, what you should do is create an array of the stations ware, then find wares of main type 5 and 6 (these are all the available factorys) and create an array from them (you can make sure there is only one in the array by using find index. Then you have a list of all the station types in the HQ, then all you need to do is use find index on them again but with your factories list and get ware count like before. This should be alot faster. Only if the player has over 300 different ware types would it be slower (and not that many people do)
User avatar
Teh_Gerbil
Posts: 148
Joined: Wed, 11. Apr 07, 04:25
x4

Post by Teh_Gerbil »

Can I install a Trading Dock in a TL with this?

More to the point... would it work properly?
-[Galactic Trade and Industry Federation - Nothing in the way of Profits]-

If the opposition disarms, well and good. If it refuses to disarm, we shall disarm it ourselves.
Joseph Stalin
B-O'F
Posts: 724
Joined: Sat, 21. Feb 04, 02:15
x3tc

Post by B-O'F »

Hi Teh_Gerbil,

The answer is no - a Trade Dock, and an Equipment Dock are not classified as factories as they do not 'manufacture' any products.

But this is still a brilliant script and idea...


Boron - Ol Fh'art
Public Service announcement

Growing old is not a disease - it is a delayed symptom of birth trauma.
MJALowe
Posts: 461
Joined: Fri, 5. Jan 07, 06:27
x3

Post by MJALowe »

being i havent actually played the game much (maybe 2 hours of actual play and few hundred of "testing") im not entirly sure what trade docks and equipment docks that are player owned actually do...if someone could explain what they do and how (with timers and all) i might be able to add them in...or make another script that does that...

note: using the EMP mod or Cyrows Script installer i could add new factories (that dont come with the game by default) by just adding a new ware to place in the HQ

@shovinus it runs the "300" (really alot less) so as to check if the factories are installed or not and install them...then it just goes ok factory is isntalled, run it...or...oh no factory...skip this section then

by stations ware do you mean the wares the factories consume/produce? or the factories themselves

most of what you wrote is going right over my head...
User avatar
arcana75
Posts: 2165
Joined: Tue, 2. Dec 03, 09:28
x3tc

Post by arcana75 »

Hey MJALowe, does this script work if the factory consumes no resources but makes products nonetheless?

I'm thinking of combining my script with urs to make a fully self-sustaining mothership, without the hassle of resupply.
MJALowe
Posts: 461
Joined: Fri, 5. Jan 07, 06:27
x3

Post by MJALowe »

yes it would, you would just have to add the needed entires to a local array or the global array (if you wanted it to work for everything)
easiest way would be the global array...

let me give you an example:

Code: Select all

else if $factnum == 215
$ware = Teladi Typhoon Missile Factory ST_17500
$produce = Typhoon Missile
$pamount = 1
$resource1 = Energy Cells S_1
$ramount1 = 216
$resource2 = Nostrop Oil L_3
$ramount2 = 144
$resource3 = Ore XL_8
$ramount3 = 36
$cycletime = 864
else if $factnum == 216
ware = the ware name of the factory
the rest are pretty much self explanatory, enter a 0 (not a null) if something isnt used

currently it would be a bad idea to enter a 0 for the produce or the first resource, though you could enter a zero for thier amounts without problem...

all the variables currently used are:

Code: Select all

$factorysettings [ $spot0 ] = $factnum

$factorysettings [ $spot1 ] = $ware
$factorysettings [ $spot2 ] = $produce
$factorysettings [ $spot3 ] = $pamount
$factorysettings [ $spot4 ] = $resource1
$factorysettings [ $spot5 ] = $ramount1
$factorysettings [ $spot6 ] = $resource2
$factorysettings [ $spot7 ] = $ramount2
$factorysettings [ $spot8 ] = $resource3
$factorysettings [ $spot9 ] = $ramount3
$factorysettings [ $spot10 ] = $cycletime

$factorysettings [ $spot11 ] = $factoriesinstalled
$factorysettings [ $spot12 ] = $cycleprogress
$factorysettings [ $spot13 ] = $factoriespayedfor
$factorysettings [ $spot14 ] = $cargofullbonusproduction
$factorysettings [ $spot15 ] = $factoriesproducing
$factorysettings [ $spot16 ] = $cycleprogressbonus
$factorysettings [ $spot17 ] = $cycletimerun
that leaves 2 empty variables per factory (assigned a 0 by default)
User avatar
arcana75
Posts: 2165
Joined: Tue, 2. Dec 03, 09:28
x3tc

Post by arcana75 »

Hmmm... purely for discussion purpose, wouldn't it have been easier to get the factory's primary resources via script than hardcode it?
MJALowe
Posts: 461
Joined: Fri, 5. Jan 07, 06:27
x3

Post by MJALowe »

i tried that first...but it generates lag (lots of lag...imagine the game freezeing for 15 seconds every minute with just 1 HQ that has 50 different factories)...and makes it less customizable...this way if i really think an SPP should produce in 60 seconds instead of 118 i can change it...or add new things

and for time taken to produce the script...ya it woulda been alot easier...

note: creating and storing arrays and reading data from them generates almost no overhead...its built in functions that generate overhead...for instance the built in function that generates a list of all player owned headquarters...or the function that gets the presence of a ware in the cargo hold (the first one runs once per minute with this script and the second one runs once for each factory per minute for each HQ, if the factory ware in my listing is 0 it skips the check)
note2: those two functions i mentioned dont generate much overhead compared to some
DarthVain
Posts: 845
Joined: Mon, 2. Jun 03, 11:53
x3tc

Post by DarthVain »

What would be awesome is the ability to build fighters. Specifically within the containment area of the Pegasus, Galactica and the Valkerie.
Another one bites the dust!!

DarthVain
MJALowe
Posts: 461
Joined: Fri, 5. Jan 07, 06:27
x3

Post by MJALowe »

if by containment area you mean docked...

well...it should be possible...i just dont know how to create a ship and have it be pre-docked....

would end up being a seperate script

other question would be how to determine what ships it can create...

would there be an EMP ware for "M3 Fighters" or would there be an EMP ware for "Nova"...either way it should be possible (once i figure out the comand for creating the ship and get a list of "construction" values (ware for specific fighter would be what i would use...otherwise you wouldnt be able to tell what ship you would get...then ofcoarse, one would probably run out of wares...so id use the cyrows script installer wares to be on the safe side....hmm....good idea for another project
Thraxwhirl
Posts: 683
Joined: Fri, 17. Feb 06, 20:54
x3ap

Post by Thraxwhirl »

This is a very novel idea. So, if I understand correctly, this scriptset enables TLs to work as kind of mobile Complexes, yes? So factories aboard them interlink - place a Crystal Fab and an SPP inside a TL and they feed each other, right?

Then, what happens to the produce? Is that stored inside the factories themselves until they can hold no more, and the excess then goes into the TL's remaining cargo space?

Reckon you ought to ensure that the TL has external docking ports so that you can ferry that produce to other stations.

You know what would be ultra cool? If you could get this script to work for Shovinus' Player-owned Shipyard. Place an Argon Federal inside your TL, and connect it up to the necessary supplying factories, and before you know it, it's rattling out fighters that end up in your empty docking slots. Lol.

Mind you, it'd probably burst if you told the SY to produce another TL or M1 inside it. Ha ha!
Last edited by Thraxwhirl on Wed, 9. May 07, 18:48, edited 1 time in total.

Return to “X³: Reunion - Scripts and Modding”