[SCR] Station Financial Manager Mk2

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
User avatar
Idea
Posts: 516
Joined: Fri, 24. Oct 08, 12:14
x3tc

Post by Idea » Sat, 17. Jan 09, 22:22

I am back.What's new.Do you need help in something?
Image

User avatar
s9ilent
Posts: 2011
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent » Sun, 18. Jan 09, 00:41

I need to do a bit more internal testing first

(And I want to actually make the command, add ship to station, cos I'm sick of doing it via the script editor, considering half the time the ship has flown off to god knows where) Hopefully by lunch (3-4hours?) , I'll have finished a satisfactory alpha.


But should you find your self completely unable to study (Be warned, Procrastination is dangerous!!!)
BE WARNED!!!, it will over write Financial recording, as its like v15 of it (no v11-14), most of the new features do work (remove all stations, add all complexes-needs work to find individual stations)

first you have to init the ships local variables, (note can't be run on player ship as their homebase = null even if they have a home base... so debugging is just adding LOTS of message logs round the place), by running the script
plugin.stat.fm.ship.add.xml on THIS (being w/e ship your testing it on, make sure HB exists first)
Next, run the actual script,
plugin.stat.fm.ship.loop.xml (Also on this)
And it should -fingers crossed- work

(Oh and make sure you've started financial what ever on the station first)


Quick run down of the loop script

Lines < 30, Does some basic checks, homebase exists, hb is saved on one of the local vars (from the add script) and its checked somewhere else. Currently the script restores the original homebase.

Line 35, Findware, This is... like the super awesome multipurpose script with 500 tools and tidbits included. It returns an array {ware,station,buy,amt,destination}
ware -next buy/sell ware (picks the best from an equation, in short, which ever is needed to be bought/sold the most, and is in range (and 2-jump range if jumper), oh and if a buy station exists.
station the station your will be buying/selling to
buy -boolean variable, whether to buy or sell the ware (this gets saved in local var plugin.stat.fm.config[1], i might consider changing to cmd target 2 thou, simply because saving it to the config[1].
amt (jump fuel adjusted if ware is energy and ship is SUPPOSE to be jump capable, ie jump is turned on)
destination where we are heading now (homebase, or station)


Line 44, setobj, sets all those configs on the ship, tells the station your landing on it
Line 50, moveone, If not in dest sect, move to next sector (or jump to sector if jumper- note self, bug, no escort jump check). If in destsect, but not in dest, dock, else do nothing. If it did nothing, it will return null, and it will skip the continue, otherwise, it'll continue, and re-findware (hopefully, its current ware should still be the highest priority, otherwise it'll fly off to the new ware)

Line 53 to seventy. TRANSACT!!! (finally?). returns null if "issues" arose (couldn't sell all, couldn't offload all, bug?).
64-68 Ill take these out later, but they are staying in for debugging atm.

Line 74+ This is run once the ship has exhausted all ware choices. Basic RTB command.
Bug note.... I haven't put in my moveone script in here yet... it's still using the stock script..



A super quick rundown of the script is
1. run checks (version, hb, etc)
2. logic check, (gets ware)
3. fly one step
4 logic check
repeat 3-4, until docked at destination (might not be original destination any more, its just what ever find ware priorities)
5. trade
6 repeat 1-5, if nothing then...
7 homebase

Known (fixed?) buglist
stat.fm.ship.add
FIXED line 4ish, pulling stat local var configs now pulls from correct array
futuremax
Fixed, line 70+, pulling shiplist array, from wrong variable
fixed did not factor buying/selling into eqn
---------------------------
future ideas list
Ships prioritze current ware, if HB is full, to prevent being looped, dump all wares into a single ship (if size >=2) prevents multiple ships being stuck with the same cargo (this way at most only one will be)will need to retask the return on... transact script (or write it into the actual transact script.. probably this way instead actually)
modify moveonescript, if docked *run fly away first* prevents crowding around the station when jumping.
Last edited by s9ilent on Sun, 18. Jan 09, 09:42, edited 5 times in total.

User avatar
Idea
Posts: 516
Joined: Fri, 24. Oct 08, 12:14
x3tc

Post by Idea » Sun, 18. Jan 09, 01:09

I take the job :D :D :D
Image

User avatar
s9ilent
Posts: 2011
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent » Sun, 18. Jan 09, 01:19

[url]http://members.optuszoo.com.au/whyistha ... /scrfm.xls[/url
This might help, it has a list of all the local/global variables
And... the priority calculations
and other misc junk

User avatar
Idea
Posts: 516
Joined: Fri, 24. Oct 08, 12:14
x3tc

Post by Idea » Sun, 18. Jan 09, 01:39

One thing.
I started the scripts but the ship dock on the homebase and do nothing.
First I stop recording on stations then start it agen.I set the homebase and start the sript.I have a lot messages logs they look like this every minute.
ARRAY(Energy Cells,Crystals,Silicon Wafers,Measteak Cahoonas)
ARRAY(0,0,0,0)
Nothing to do

My homebase is Crystal Fab M race Argon sector Argon Prime.
They station do not have ware on it.It is empty.
Last edited by Idea on Sun, 18. Jan 09, 01:50, edited 1 time in total.
Image

User avatar
s9ilent
Posts: 2011
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent » Sun, 18. Jan 09, 01:46

Hrm... set the ship to idle (so it leaves the station)
, and run the script


$ret = plugin.stat.fm.findware on the ship
write to logbook $ret


One of the things about how the script works, is that it ALWAYS works on wares in its inventory first. So if the station is full and it has wares, it will just sit there, trying to continuously unload. Thats the usual culprit for me


It should return the current objective, and also it might print off an array of all wares of the station, and a list of numbers with it.
Tell me what it gives you (Oh and whats the homebase)

User avatar
s9ilent
Posts: 2011
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent » Sun, 18. Jan 09, 01:52

Are there stations within the stations max range, with the good prices?


From the ouput, it's saying that all tasks have priority 0. So they are either all at 100% stock (or 0 from products) (which is unlikely), or there are no stations within range

User avatar
s9ilent
Posts: 2011
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent » Sun, 18. Jan 09, 02:10

Yeh, just double checked my script, priority = 0 is returned when.. either the priority IS 0 (i.e stock is near 100 and/or distance is far away enough)
or when there is no station.

I'm going to change the no station priority to -1 thou to make it more distinguishable (Although the ship still won't act unless prio > min prio)

User avatar
Idea
Posts: 516
Joined: Fri, 24. Oct 08, 12:14
x3tc

Post by Idea » Sun, 18. Jan 09, 02:14

I set command on idle,the shup come out of the station and he do nothing.I start the script plugin.stat.fm.findware and still nothing.Then I start form
beginning plugin.stat.fm.ship.add.xml after that plugin.stat.fm.ship.loop.xml
And he start to go for Silicon Wafers in Silicon mine in Duke's Vision.
Message logs:
ARRAY(Energy Cells,Crystals,Silicon Wafers,Measteak Cahoonas
ARRAY(5,0,171,129)

765

null

416

764 then agen

ARRAY(Energy Cells,Crystals,Silicon Wafers,Measteak Cahoonas
ARRAY(5,0,171,129)

765

null

413

764 then he found the station were the ship go to
ARRAY(Silicon Wafers,Silicon Mine M beta(Duke's Vision) 1,764 Silicon Mine M beta(Duke's Vision))

Silicon Mine M beta(Duke's Vision)

flyin to sect

can jump

Then the ship jump 5 sectors form Argone Prime to Emperor Mines
I will be watching the behavior of the ship.The jump range I set is 20.Sory for my slow answer English is not my nativ language so I have difficulties to answer fast :(
Image

User avatar
Idea
Posts: 516
Joined: Fri, 24. Oct 08, 12:14
x3tc

Post by Idea » Sun, 18. Jan 09, 02:28

:evil: :evil:
At the moment the ship come through the gate from Preacher's Void to Duke's Vision agen log meesage:

ARRAY(Energy Cells,Crystals,Silicon Wafers,Measteak Cahoonas)

ARRAY(0,0,0,0)

Nothing to do

Crystal Fab 1(Argon Prime) an the he turn around and heed back to homebase. :evil:
Image

User avatar
s9ilent
Posts: 2011
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent » Sun, 18. Jan 09, 02:34

Hrm... something is wrong with my ware finder... Hold one.. I'll have to find it..

User avatar
Idea
Posts: 516
Joined: Fri, 24. Oct 08, 12:14
x3tc

Post by Idea » Sun, 18. Jan 09, 02:38

I check with Universal buys/sells and in Duke's Vision was the closest with best price of 232 for Silicon Wafers but also Silicon Mine M gama had the same price and that mine was closer to the North gate then Silicon Mine M beta.
Image

User avatar
s9ilent
Posts: 2011
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent » Sun, 18. Jan 09, 02:46

Hrm..
I haven't made an in sector distance checker yet. I just assumed the command would automatically do it.

(Found the problem I was having earlier... i was running on THIS and not on the ship :S no wonder why I kept getting 0's)

But yeh... I see what you mean.. its randomly flying backwards and forwards between the stations....
Mines stuck between majaglit alpha and beta
Ill have to refine the find sta list

bug fix, future max no longer counts current ship
(prevents wierdness with with amt)

Ill try to fix up this multiple stations business, then I'll re upload
Last edited by s9ilent on Sun, 18. Jan 09, 02:57, edited 2 times in total.

User avatar
Idea
Posts: 516
Joined: Fri, 24. Oct 08, 12:14
x3tc

Post by Idea » Sun, 18. Jan 09, 02:50

I accidentally increased the price for buying wares in station and my EST fill it up.That probably trigger the ship to go back.I will reduce it ageen :oops:
Image

User avatar
s9ilent
Posts: 2011
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent » Sun, 18. Jan 09, 03:04

Ok I worked out "why" the ship is bouncing around different stations.

It is finding the closest station BUTTT, I make it recheck when docked, and when its docked, it has no co-ordinates (position null). So the nearest is just the nearest to 0-0-0, but if i make the ref obj the station, then it doesn't count it in the search.

So... *sigh* dodgy work around required...

Post Reply

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