I tried this mod but the ship idles for too long, then waits for signal and return to idling.

Yes, feedback seems to indicate that the idle time between trade runs is indeed to long. I will reduce this in next version.

The traders work strictly within the constraints the player sets up. If there are no acceptable trade offers available they just wait. Double check the setup and check if there are acceptable trade offers from vendors and customers. Note, that the prices you see on the map include discounts. However, the traders do not see these discounts. For example, you see a vendor selling energy cells for 10 Cr, but the trader sees the same offer as selling at 12 Cr. The next version will include a "Report to logbook" option that will print the current demand/supply situation at vendors and customers.

Sure, I couldn't find a way to change the buy price in-game, so I had to dig in the save's xml to edit the overrides myself. Not exactly user-friendly, i'll grant you that
But once that was done, it worked like a dream !
The wares only apprar in the logistical overview once there is at least one unit in stock though, but then you can set the sell prices from there as you want, add or remove auto pricing without affecting your buy prices.

Now all you need is a way to see the buy offers in the logistical overview, so you can set the prices there, and the mod will be ready in my opinion for a beta release.

The only small bug I encountered : when I asked my station to build itself some drones, the order my manager put in for drone parts, e-cells and smartchips overwrote my buy prices and deleted my sell order for these wares.
But really, given how AMAZING it is to finally have my trade station, it's a very minor annoyance.

Thanks so much ! And all this from repurposing an AI script. The greatest effect from the smallest of changes, a true master of code at work

I'm a huge fan too of it too. Makes so many more options available! Not just for selling but also storage and distribution.

The next thing I will do in my current playthrough is to build a warehouse and experiment with the script myself. I hope I will be able to release it soon.

And yet it's still something I need !
The ability to use a varied basket of wares is the only thing that can make L freighters viable (as long as they don't have many gates to go through).
(Also noticed L miners can mine several resouces at once ! Only vanilla ship I've seen handle more than 1 ware. Really helps keep their productivity on par with a good M miner, at least, since they can fill up surprisingly fast.)

Adding your script to my next test run (I'll try to restrain myself from modding it further, to give useful feedback. But I almost compulsively mod every game and mod I play...).

Overall, the scripts work absolutely great ! As you said, they do make trade runs with 0 profit when they have no better option, which is very useful, no other script will do it. Still *a little* too much idle time between runs, but light-years beyond vanilla behaviors .

I have made max idletime depend on pilot morale, currently max morale results in idletimes from 5s to 10s, while a pilot with zero moral idles between 5s and 70s. I will reduce this for the next version.

One caveat : this maybe linked to the the vanilla behavior of station managers, but I can't get your scripts to buy up any ware that the station uses. For ex. : My station produces a lot of E-cells, and consumes a few of them. Your traders will never buy e-cells from this station ever, they'll just idle if they have no other supplier. Probably because the wares are marked by the manager as 'must store' because they are used in production, even when the storage for them is full...
That behavior was consistent on every station : wares that were used were never sold, wares not used were sold without problem. Only exception : food and meds, sold without problem even though pops consumed it.

Does the manager create sell offers for energy cells? Is the offered amount above min amount and is the sell price below max buy price? From X Rebirth I have learned not to trust managers to put up sell offers for intermediates. So if I want to have a station A to produce ware W for other stations B, C, ... I make sure that station A has no productions that use ware W as a resource.
If the sell offer is present and if the conditions are right, then that would be bug in my script. I have uploaded a new version to the experimental branch, that has option for the trader to report the offers, including amount and prices, he sees to the logbook. Might help to investigate this further.

And I say 'sold', but I noticed something strange : the stations didn't get nor spend a dime for these trades (all happening between player-owned stations). My trade station bought everything my factories made but the budget never moved a single cent, even though I was selling nothing yet, only buying.

Yes, trades between player assets do not exchange money, at least not when the player acount is involved. I hope this will be different when they are assigned to a station.

Also tried your script on a few mining ships : worked great. The only problem is that it uses resource probes, and they never worked right for me. Must have dropped 30 probes at various resource-filled spots in Nopileo's Fortune, only 3 ever gave me readings, so the other ones couldn't be used as 'vendors'. And they vastly underestimate available resources : one probe was showing almost 0 ice density, and my miner with your script was idling waiting for ice to be available at the probe. But a vanilla miner was happily mining a huge ice asteroid less than 3 km from the probe, and I saw a lot more ice around. So it would probably work a lot better if we could set a whole system as 'vendor' instead of a resource probe, as they are problematic.

Try to set min amount to 1. The current implementation, finds resources within 100km of the resource probe if the probe reports a yield of at least min amount. I'm not quite happy with the current implementation either, but finding resources anywhere within a sector feels too cheaty to me. Maybe I could have it also accept navbeacons and disable the yield check in that case.

One quality-of life request : it would be useful if the ships could get as commander the first player-owned station they find in their buyer and seller lists. That way they don't clutter the 'unassigned ships' section of the UI.

You will get an explicit option to set a home base/beacon where they will return to when there is nothing to do and an option to assign the trader to that home base.

But these scripts still THINK, check prices, idle a little, all that.
Sometimes that's what you need, but mostly I need something even simpler : a basic order loop.

Go to station A => Pick up ware => Go to station B => Drop ware => Back to station A. That's it, no idle time, no recrimination.

You can go a bit fancier :
Goto A => Check if enough ware to fill cargo => Wait until true, then pick up => Goto B => check if space in storage, then drop => Back to A.

Now the deluxe version, that's on top of my wishlist

Same as before, but with potentially several suppliers and buyers.
BUT : the script ALWAYS buys from vendor 1 if enough to fill cargo. If not, only then do you check vendor 2, then 3, etc.
Same with several customers : always sell to customer 1 if enough space to take the delivery. If not, only then do you check customer 2.

That way the script has almost no calculations involved, so can loop orders without lag, and most importantly it behaves in an entirely deterministic manner. That would be just perfect.

As an added bonus, if those scripts can drop cargo into a station 'non-consensually', even if the station has no buy order for it, that can be enough to create a rudimentary trade station. Once you have a ware in inventory, you can set a sell offer and manage the price from the logistical overview. You then just need to keep force-feeding more wares into it, instead of having buy offers.

Computation time of my scripts is probably neglectable compared to AutoTraders. I guess the lag you see is caused by skill based idle times.

I might add a dedicated script that is optimized for internal distribution of a single ware. I still think it is safer to base it on trade offers and make it prioritize first on price then on quantity.

Sure, I couldn't find a way to change the buy price in-game, so I had to dig in the save's xml to edit the overrides myself. Not exactly user-friendly, i'll grant you that
But once that was done, it worked like a dream !
The wares only apprar in the logistical overview once there is at least one unit in stock though, but then you can set the sell prices from there as you want, add or remove auto pricing without affecting your buy prices.

Maybe there is way to set price and quantity by script. I have to experiment with it.

The only small bug I encountered : when I asked my station to build itself some drones, the order my manager put in for drone parts, e-cells and smartchips overwrote my buy prices and deleted my sell order for these wares.

And yet it's still something I need !
The ability to use a varied basket of wares is the only thing that can make L freighters viable (as long as they don't have many gates to go through).
(Also noticed L miners can mine several resouces at once ! Only vanilla ship I've seen handle more than 1 ware. Really helps keep their productivity on par with a good M miner, at least, since they can fill up surprisingly fast.)

Adding your script to my next test run (I'll try to restrain myself from modding it further, to give useful feedback. But I almost compulsively mod every game and mod I play...).

Thanks !

It still only handles one ware. Would get tricky to do more than one at a time. Eh, don't want to derail this thread, hit me up in the other if you want to discuss.

Thanks for making this - really handy (especially the build supply part!). One question though: does money still change hands even when all the trades are between your own station? One of my build supply points has ended up with negative 13 million credits, and I'm wondering if this could be the reason.

EDIT: This could be related to the negative credits issue, but I'm also seeing my building supply freighters entering a pattern where they'll fill up with wares, and then just fly randomly in circles indefinitely

judging by the description this is A good mod , from stations a to sell stations B and C goods . But that would make the trader bought at the station energoalmaty sold at the station B , and then bought at the station B, other merchandise and sold the station and then went back to the station And all over again.

Just a small question: Would it be possible to add a toggle in the order creation form to assign a specified ship under a station? It is mainly so to reduce the clutter in the main ship window. (Something alike what Station Mule mod does).