[WIP/MOD] Supply And Trade Routes (including build supply and mining)

The place to discuss scripting and game modifications for X4: Foundations.

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

TheDeliveryMan
Posts: 253
Joined: Sat, 10. Dec 11, 04:10
x4

Re: [WIP/MOD] Supply And Trade Routes (including build supply and mining)

Post by TheDeliveryMan » Fri, 4. Jan 19, 13:40

AttilaTheHunk wrote:
Fri, 4. Jan 19, 06:22
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.

TheDeliveryMan
Posts: 253
Joined: Sat, 10. Dec 11, 04:10
x4

Re: [WIP/MOD] Supply And Trade Routes (including build supply and mining)

Post by TheDeliveryMan » Fri, 4. Jan 19, 14:28

leecarter wrote:
Fri, 4. Jan 19, 13:35
LegionOfOne wrote:
Thu, 3. Jan 19, 22:49
SpoilerShow
It works !!!! My god it's amazing, I could kiss you right now !

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.
leecarter wrote:
Fri, 4. Jan 19, 13:35
viewtopic.php?f=181&t=411837
Nice and simple solution.

LegionOfOne
Posts: 52
Joined: Sun, 16. Dec 18, 14:16
x4

Re: [WIP/MOD] Supply And Trade Routes (including build supply and mining)

Post by LegionOfOne » Fri, 4. Jan 19, 16:26

leecarter wrote:
Fri, 4. Jan 19, 13:35
It's not exactly what you described as wanting
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 !

TheDeliveryMan
Posts: 253
Joined: Sat, 10. Dec 11, 04:10
x4

Re: [WIP/MOD] Supply And Trade Routes (including build supply and mining)

Post by TheDeliveryMan » Fri, 4. Jan 19, 19:31

LegionOfOne wrote:
Thu, 3. Jan 19, 22:49
After my first round of testing, I have some feedback.
Thanks for the feedback.
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.

TheDeliveryMan
Posts: 253
Joined: Sat, 10. Dec 11, 04:10
x4

Re: [WIP/MOD] Supply And Trade Routes (including build supply and mining)

Post by TheDeliveryMan » Fri, 4. Jan 19, 20:06

LegionOfOne wrote:
Thu, 3. Jan 19, 22:49
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.
LegionOfOne wrote:
Thu, 3. Jan 19, 22:49
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.
I have no idea if that is even possible to mod. Right now my script is just workaround for a missing vanilla feature.

LegionOfOne wrote:
Thu, 3. Jan 19, 22:49
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.
I don't think this is something I can prevent.

leecarter
Posts: 374
Joined: Sat, 9. Sep 06, 22:35
x3tc

Re: [WIP/MOD] Supply And Trade Routes (including build supply and mining)

Post by leecarter » Sat, 5. Jan 19, 01:13

LegionOfOne wrote:
Fri, 4. Jan 19, 16:26
leecarter wrote:
Fri, 4. Jan 19, 13:35
It's not exactly what you described as wanting
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.

TheDeliveryMan
Posts: 253
Joined: Sat, 10. Dec 11, 04:10
x4

Re: [WIP/MOD] Supply And Trade Routes (including build supply and mining)

Post by TheDeliveryMan » Sun, 6. Jan 19, 21:41

My current work in progress is available here: https://github.com/TheDeliveryMan/TDM_S ... perimental

New features:
  • Set a home base or navbeacon where the freighter will return to when there is nothing to do
  • Option to assign the freighter to the home base
  • Recon default behaviour for scouts to keep trade info of their area of operation uptodate. About 10 scouts are enough to cover the whole friendly X4 universe. No need for satellites.

DIox
Posts: 2
Joined: Tue, 8. Jan 19, 11:11

Re: [WIP/MOD] Supply And Trade Routes (including build supply and mining)

Post by DIox » Tue, 8. Jan 19, 11:21

Thx for all your hard work. I really love this mod and can't wait to try it out. My favourite mod at this time, still refreshing site waiting for new updates :)

Baldamundo
Posts: 76
Joined: Sat, 21. Jun 08, 18:46
x4

Re: [WIP/MOD] Supply And Trade Routes (including build supply and mining)

Post by Baldamundo » Fri, 11. Jan 19, 14:34

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

Replik1987
Posts: 12
Joined: Mon, 1. Oct 18, 20:26
x4

Re: [WIP/MOD] Supply And Trade Routes (including build supply and mining)

Post by Replik1987 » Sun, 20. Jan 19, 11:55

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.

User avatar
nidaren
Posts: 65
Joined: Wed, 27. Nov 13, 15:33
x4

Re: [WIP/MOD] Supply And Trade Routes (including build supply and mining)

Post by nidaren » Mon, 21. Jan 19, 02:03

Hello!

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).

Huge thanks!

User avatar
ThalonMook
Posts: 1289
Joined: Tue, 3. Feb 04, 13:11
x4

Re: [WIP/MOD] Supply And Trade Routes (including build supply and mining)

Post by ThalonMook » Fri, 25. Jan 19, 14:04

Hi,

thx for this mod. I use it to resupply my fabs.
I tried to use it for my hullpart fab. I want that the freighter will get hullparts form the fab and store it into the buildstorage but this will not work.

Any hints?

Cu
Thalon

Dani_Gecko
Posts: 40
Joined: Fri, 27. Nov 15, 22:30
x4

Re: [WIP/MOD] Supply And Trade Routes (including build supply and mining)

Post by Dani_Gecko » Fri, 22. Feb 19, 12:59

ThalonMook wrote:
Fri, 25. Jan 19, 14:04
Hi,

thx for this mod. I use it to resupply my fabs.
I tried to use it for my hullpart fab. I want that the freighter will get hullparts form the fab and store it into the buildstorage but this will not work.

Any hints?

Cu
Thalon
I've been looking for this in the modding forums for 2 hours now. I would like to have a simple script like in X3. A freighter shipping wares in a loop between 2 points - without user interaction. Nothing fancy. Just from my factory to my building storage. There is no way in X4 to put a loop of any kind for a frighting command. Every time you want a ship to transport something, you have to give the explicit command.

pseudo codeShow
until (...) amount of ware of type [a] at point [Z]
>get ware of type [a] at Place [A, B... Y]
>unload ware of type [a] at point [Z]
end
Can somebody point me at something like that? Or can OP please add this functionality?
Cheers!

EDIT_1: I read the instructions again ... more carefully and it seems this mod does have the functionality. It just needs a manager to be put in place. Trying it right now.

EDIT_2: I think there is a issue when you try to self-feed a station. My guy picked up the stuff all right but they refuse to drop the cargo at the build storage. I see it flicker very short for a path indicator back to the station. But no indicator to the storage comes up and they just circle around the station as in idle mode. The station has a manager appointed and free docking space for a M class ship. I link a picture: https://imgur.com/a/DMme6Cv

swatti
Posts: 1249
Joined: Sun, 7. Dec 03, 13:03
x4

Re: [WIP/MOD] Supply And Trade Routes (including build supply and mining)

Post by swatti » Fri, 22. Feb 19, 17:50

REQUEST: "Anything goes" -build mode.

Choose a build-site, choose a ware to supply and hit "confirm"
Find the stuff, anywhere, at any price.

Listing tons of vendors for many ships gets sloooow.

nickolaiproblem
Posts: 87
Joined: Tue, 6. Nov 18, 00:12
x4

Re: [WIP/MOD] Supply And Trade Routes (including build supply and mining)

Post by nickolaiproblem » Fri, 1. Mar 19, 04:37

Can you add more trade ware options please also thanks for the mod.

Post Reply

Return to “X4: Foundations - Scripts and Modding”