[MOD] Station Mule - Multiple ware station supply

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

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

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

[MOD] Station Mule - Multiple ware station supply

Post by leecarter » Fri, 4. Jan 19, 03:56

Most trader mods are based on how much money they can make across a wide number of offers or allow you to focus on single ware transfer between two stations. Both of these approaches are quite good, but I wanted one ship to haul ALL of the goods being produced in one station that are needed by a second station. So I made Station Mule.

My intention when I wrote this was to set up a supply chain between my own stations, which is the scenario I've been testing with as I wrote it. However, I put no player only restrictions on it, so you should be able to set up a Station Mule using one or both choices as AI stations if you wanted to. Let me know how that goes if you do. Maybe you can actually keep a shipyard running. :P

To setup:
* Select a ship floating in space with no orders and preferably no cargo.
* Select StationMule from the trade menu.
* Pick the source station - this is where Station Mule will be looking to haul (buy) from.
* Pick the target station - this is where Station Mule will be looking to haul (sell) to.
* If the target station is one owned by you, ensure there is money in it's account.
* "Assign to source" will assign it to the source station if you own it, this is just a convenience I put in to get Station Mule off my unassigned ships list and keep things tidy. It has no effect on what he does other than where the money goes.
* "Include energy cells" is if you want Station Mule to haul those. Since Station Mule selects based on how much the target station needs and energy cells have a much higher ware limit he might be hauling those more than you'd want him to.

Note: While the trade selection is based on the target station's need, sometimes the supply station's manager is stingy and only puts up small sell offers for him to haul. I can't control this.

Install in the extensions folder. To remove delete the StationMule folder. Does not cause your saves to lock on it.

Get it here:
https://www.nexusmods.com/x4foundations/mods/237
Last edited by leecarter on Fri, 4. Jan 19, 23:35, edited 1 time in total.

ApoxNM
Posts: 777
Joined: Wed, 5. Dec 18, 06:17
x4

Re: [MOD] Station Mule - Multiple ware station supply

Post by ApoxNM » Fri, 4. Jan 19, 06:08

Link says not published!

Invasion
Posts: 212
Joined: Tue, 11. Dec 18, 10:14

Re: [MOD] Station Mule - Multiple ware station supply

Post by Invasion » Fri, 4. Jan 19, 06:58

Very nice. This seems to be the first trader mod specifically designed for setting up supply lines.

However how will the trader handle wares that are set as restrict faction trading? This is a consideration at both ends.

And can it be set up with open ended instructions? For example having the trader buy only from my medical supplies factory to supply all my other stations. Or the trader buying wares from all other owned stations, to supply only one of my stations.

This open ended capability will be the absolute bees knees when we get our shipyards and wharfs in 2.0, because those stations need to be able to source a multitude of wares and people are going to want to confine it to only their own stations as suppliers.
<Blunt Threadslayer>
Making you sweat today, so you won't have to bleed tomorrow

cdeeks
Posts: 89
Joined: Tue, 22. Jan 13, 20:38
x3tc

Re: [MOD] Station Mule - Multiple ware station supply

Post by cdeeks » Fri, 4. Jan 19, 11:34

Link is broken

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

Re: [MOD] Station Mule - Multiple ware station supply

Post by leecarter » Fri, 4. Jan 19, 12:20

Sorry about that, finished it right before bed and was sleepy, it's published now.

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

Re: [MOD] Station Mule - Multiple ware station supply

Post by leecarter » Fri, 4. Jan 19, 12:28

Invasion wrote:
Fri, 4. Jan 19, 06:58
Very nice. This seems to be the first trader mod specifically designed for setting up supply lines.

However how will the trader handle wares that are set as restrict faction trading? This is a consideration at both ends.

And can it be set up with open ended instructions? For example having the trader buy only from my medical supplies factory to supply all my other stations. Or the trader buying wares from all other owned stations, to supply only one of my stations.

This open ended capability will be the absolute bees knees when we get our shipyards and wharfs in 2.0, because those stations need to be able to source a multitude of wares and people are going to want to confine it to only their own stations as suppliers.
I had supply lines and production/storage hubs in mind when I made this. I just wanted to move stuff. It'll be great when player trade stations and shipyards are available.

I would imagine a buy/sell offer wouldn't appear if the trade was restricted on the ship owners faction, didn't test that though. This is just source to target stations, not multiple target stations, but that's a cool idea. I could see it being an issue if you based it on quantity needed and one station had a large storage module while the other had a small one.

LegionOfOne
Posts: 122
Joined: Sun, 16. Dec 18, 13:16
x4

Re: [MOD] Station Mule - Multiple ware station supply

Post by LegionOfOne » Mon, 7. Jan 19, 03:42

Invasion wrote:
Fri, 4. Jan 19, 06:58
And can it be set up with open ended instructions?
I feel this script is just fine as it is, it is a perfect tirelessy working bee.
For more complex internal supply routes, involving more than two stations, I suggest this.
I don't use these to trade with npc stations though, just between mine. There's tatertraders or autotraders for foreign trade.

And just so you know, players can now have their own warehouses and trade stations !

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

Re: [MOD] Station Mule - Multiple ware station supply

Post by leecarter » Mon, 7. Jan 19, 04:12

LegionOfOne wrote:
Mon, 7. Jan 19, 03:42
I feel this script is just fine as it is, it is a perfect tirelessy working bee.
For more complex internal supply routes, involving more than two stations, I suggest this.
I don't use these to trade with npc stations though, just between mine. There's tatertraders or autotraders for foreign trade.

And just so you know, players can now have their own warehouses and trade stations !
Yeah it's easy to set up and does one thing very well so I'm going to leave it be. As soon as you start increasing the functionality you also increase the complexity and number of bugs to stomp out. If you go to my nexus account page from the link above you'll see a Skyrim mod I made that has going on 100,000 downloads. That thing became an over complicated beast, not to mention the never ending stream of complaints, forum posts, and private messages from people who 95% either didn't install it right or had a conflicting mod they expected me to fix for them.

Anyway, point is I learned you'll never make everyone happy. And while I have some other ideas for small mods that I might do, I'll make them to do what I want and people can use them or take a pass. Because as as far as being a popular modder goes, my feelings can best be summed up with this clip:

https://www.youtube.com/watch?v=EKfgHfHbzAM

LegionOfOne
Posts: 122
Joined: Sun, 16. Dec 18, 13:16
x4

Re: [MOD] Station Mule - Multiple ware station supply

Post by LegionOfOne » Mon, 7. Jan 19, 21:06

leecarter wrote:
Mon, 7. Jan 19, 04:12
Yeah it's easy to set up and does one thing very well so I'm going to leave it be.
After a bit of further testing, I have one small complaint : the script too often chooses to make a half-full run :rant:
A description of the problem, this can happen to you :)
Show
I have a station making four wares, that I am trying to sell to another station. All trades are for zero profit, so that's not a factor.
The traders using that script seem to be picking wares in order : they will pick ware A first, then B if there is no stock of A.
Result, they never pick up ware D, sometimes make full runs of ware C, but most of the times make 9/10th empty runs with the little quantities of A or B I just produced.

I'd like them to only make trade runs with a full cargo, but at worst, if they could just pick a *random* ware every time...
I'm trying to mod that in myself if you've got other things to focus on, I'll PM you the results if they're interesting. But if you can provide it that's fine too :)
Edit : I have an idea
Show
Your current script actually prioritizes the needs of the buying factory, which is very useful to feed a factory with intermediary products at the right pace.
But I also want a version that focuses on moving vast amounts of wares to my Trade Station, I just want them to empty all these storages of finished products :)
So if we can find a way to inverse the priority and sort trades on the stock of the seller instead, we can have a second version of the script that would be useful too.
I'll try, but I'm a bit new to modding AI scripts.

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

Re: [MOD] Station Mule - Multiple ware station supply

Post by leecarter » Tue, 8. Jan 19, 00:15

LegionOfOne wrote:
Mon, 7. Jan 19, 21:06
After a bit of further testing, I have one small complaint : the script too often chooses to make a half-full run :rant:

I have a station making four wares, that I am trying to sell to another station. All trades are for zero profit, so that's not a factor.
The traders using that script seem to be picking wares in order : they will pick ware A first, then B if there is no stock of A.
Result, they never pick up ware D, sometimes make full runs of ware C, but most of the times make 9/10th empty runs with the little quantities of A or B I just produced.

I'd like them to only make trade runs with a full cargo, but at worst, if they could just pick a *random* ware every time...
It's prioritizing on what the target station needs the most of, as in a raw count of numbers. So in my testing my station needed 1500 refined metal but only 200 antimatter cells. The result being the ship would run multiple loads of refined metal until the inventory got below 200, then it switches over to antimatter cells. It's a fire and forget script, it'll get around to all the wares eventually. If you're in more of a rush then try a different approach or assign multiple mules to the station. As for the amount of cargo being hauled, see below.
LegionOfOne wrote:
Mon, 7. Jan 19, 21:06
Your current script actually prioritizes the needs of the buying factory, which is very useful to feed a factory with intermediary products at the right pace.
But I also want a version that focuses on moving vast amounts of wares to my Trade Station, I just want them to empty all these storages of finished products :)
So if we can find a way to inverse the priority and sort trades on the stock of the seller instead, we can have a second version of the script that would be useful too.
I'll try, but I'm a bit new to modding AI scripts.
In my testing I noticed the seller station was sometimes only offering trades of small amounts, so there might be 1000 of something in the station, but the dummy manager would only sell 100 so that's what the ship would haul. I wrote it off to the station manager being a d**k and moved on, if you find a workaround that doesn't involve directly fudging the trade offer quantities (bad idea imo) let me know.

This is exactly what inspired me to work on my current script, which involves basically telling the manager to fig off with his trade deals and I'll just take what I please.

LegionOfOne
Posts: 122
Joined: Sun, 16. Dec 18, 13:16
x4

Re: [MOD] Station Mule - Multiple ware station supply

Post by LegionOfOne » Tue, 8. Jan 19, 00:30

My trade station has 600M m3 of storage, my manager is trying to fill it all with his buy orders, and my production station is trying to sell enough of everything, so that's not my problem.
It's the sorting order of wares.
But I always find a way to have my way :wink:

Edit : also,
leecarter wrote:
Tue, 8. Jan 19, 00:15
This is exactly what inspired me to work on my current script, which involves basically telling the manager to fig off with his trade deals and I'll just take what I please.
I couldn't agree more ! I've seen hints in the logistical overview UI about setting the volumes of the offers manually, I'll tinker in that direction.
To quote a comment in there : -- TODO : enable slider handles for buy/sell limits?
I'll see if I can get there before they do :)

LegionOfOne
Posts: 122
Joined: Sun, 16. Dec 18, 13:16
x4

Re: [MOD] Station Mule - Multiple ware station supply

Post by LegionOfOne » Wed, 9. Jan 19, 04:41

leecarter wrote:
Tue, 8. Jan 19, 00:15
the dummy manager would only sell 100
I observed that kind of trade volume limit only on buy offers for wares the station needs, and sell offers on wares the station produces but still uses too. So e-cells, food and meds are always a problem.

But a sell offer on a ware the station produces and doesn't use will always be for all the available cargo.
Also, buy offers on player trade stations are always for (max of reserved cargo space - current stock) and sell offers are always for all they have :)

And after getting a taste of efficient trading, I just can't use another script that's more complicated and slow than this one and the Supply and Trade Routes script.
Once you feed everything you make into one warehouse, it's very easy to set up mules from the warehouse to each NPC trade station, shipyard, wharf, and dock you want to sell to.
To deliver to smaller NPC stations that don't consume enough to have their own trader, a few STR traders set up to deliver from the warehouse to several small customers works great and fast too.

The galaxy will never buy from another supplier again ! :)

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

Re: [MOD] Station Mule - Multiple ware station supply

Post by leecarter » Thu, 10. Jan 19, 02:33

LegionOfOne wrote:
Wed, 9. Jan 19, 04:41
leecarter wrote:
Tue, 8. Jan 19, 00:15
the dummy manager would only sell 100
I observed that kind of trade volume limit only on buy offers for wares the station needs, and sell offers on wares the station produces but still uses too. So e-cells, food and meds are always a problem.

But a sell offer on a ware the station produces and doesn't use will always be for all the available cargo.
Also, buy offers on player trade stations are always for (max of reserved cargo space - current stock) and sell offers are always for all they have :)

And after getting a taste of efficient trading, I just can't use another script that's more complicated and slow than this one and the Supply and Trade Routes script.
Once you feed everything you make into one warehouse, it's very easy to set up mules from the warehouse to each NPC trade station, shipyard, wharf, and dock you want to sell to.
To deliver to smaller NPC stations that don't consume enough to have their own trader, a few STR traders set up to deliver from the warehouse to several small customers works great and fast too.

The galaxy will never buy from another supplier again ! :)
I'm putting the game aside until player shipyards are a thing (officially - one lost save to that mod is enough). Without them the end game falls totally flat because you're forever dependent on other factions for the single most important manufactured item in the game. Anyway, if you have changes or improvements feel free to post them up, there isn't a dime to be made here so I couldn't care less. I've already got some jag-off on my nexus comments board yelling at me in all caps about how I need to change the mod to fix a situation the mod had nothing to do with creating in the first place. Like I said a few posts up, been there done that.

LegionOfOne
Posts: 122
Joined: Sun, 16. Dec 18, 13:16
x4

Re: [MOD] Station Mule - Multiple ware station supply

Post by LegionOfOne » Thu, 10. Jan 19, 12:08

With leecarter's blessing, here is a newer version of the script, that includes a few more options we worked on together. Do not blame him if something doesn't work though :)

If the download is at the end, you'll just skip there, so here it is : Download Link !

But you should probably still read the rest of this post :
DISCLAIMER
Show
I don't post mods myself as a rule. The last time that happened was around two decades ago, and it stopped pretty much for the reasons leecarter described.
I only mod for my own enjoyment. I usually simply share my best bits of code directly with other modders, so if they are useful they get cleaned up and integrated in a mod somewhere.
I will make a small exception here because I understand leecarter's decision well, but I include the following clauses:

NO WARRANTY IS INVOLVED

YOU MAY NOT : make any form of request

YOU CAN :
- Ask for help about potential bugs on this thread. Someone useful may answer. Insisting probably won't help.

- Suggest new features here. If I like them, and they leave the script as simple and fast as now, there is a decent chance I will include them and provide them here.
Before doing that though, look at this script, it is very useful and fast too, and may already do what you want.

- PM general questions about modding and making your mods work to me. No guarantees there too, of course, but if I know something useful and have the time, I'm usually happy to help.
And sometimes, I get nice new mods to play with thanks to that. So it doesn't hurt to ask.


Also, I can share a few things I learned about how to make the best use of this script, and set up an entirely autonomous network of stations with it, if it is useful to you all.

That's it, I hope you enjoy the new features.
List of Features :

- Basic Mode :
The default behavior of a Mule is to look at the wares the Target station needs (and the Source station sells), and find the one with the largest buy order.
So if the Target is trying to buy 500 units of ware A and 1000 units of ware B, the Mule will ALWAYS choose B.
After a few deliveries, the Target will need less than 500 units of ware B, so the Mule will switch to ware A, and so on as needs evolve.

By default, Mules do not trade Energy Cells, Food Rations or Medical Supplies. They freely trade illegal wares.

You can activate various small options to fine-tune your Mule's behavior :

- Allow Energy Cells
- Allow Food and Meds
- Forbid Illegal Wares
- Allow only illegal wares, creating the obviously-named DrugMule.

Finally, Seller Priority inverts the way the Mule chooses a trade. Instead of looking at what the Target Station needs most of, it looks at what the Source station has the largest stocks of.

Mules work the same between player-owned stations and when trading with NPC stations.
BUT : they do not look at prices AT ALL, let alone calculate profits. They do not care. You told them to buy somewhere and sell somewhere else, they do it.
They are perfect little drones who never think, just obey a few simple commands.
They are entierely deterministic : in a given situation, they will always choose the same trade, as explained above.
If it involves a NPC station, the Mule will pay or get paid through its commander's account.

To make the best use of them despite their limit of one supplier and one buyer, I highly recommend the Player-Owned Warehouses mod.
You can use Mules to sell everything you make to your Warehouse, and use Mules to sell everything in your Warehouse to your own stations, and to every NPC Trade Station, Shipyard and Dock out there.
And to answer leecarter's question in the OP, it is perfectly possible to keep a Shipyard well-supplied like that, and simple to set up.
If your Mule is not moving
Show
Do not kick it just yet.

First, check if the source station has some stock of a ware the target station wants.
If true, then look at the volumes of the buy offer and sell offer. Sometimes, stations managers keep stuff for themselves and don't want to sell, or buy for some reason. Don't ask.
Finally, check that there is cash in the station's account, just in case :)

If you don't find why your Mule isn't moving with that, maybe do try kicking it :
Remove the current orders and free it from its commander, then give it orders again.

If it still doesn't move, you may be beating on a dead mule, and this may be a genuine bug.
Try to include all the details above if you report a bug, it might help.
You can try including a savegame and the name of your Mule, for debug and funeral purposes.

All donations should go to your favourite Mule shelter.
With all that, you can make them do a lot of different things already, and watch them do it faster and easier than any other script I tested. And I tested :)


Have fun !

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

Re: [MOD] Station Mule - Multiple ware station supply

Post by Baldamundo » Fri, 11. Jan 19, 13:52

This is really useful compared to the vanilla station traders, thanks for making it!

Btw, does money still get transferred between accounts when all the trades are between player-owned ships and stations?

LegionOfOne
Posts: 122
Joined: Sun, 16. Dec 18, 13:16
x4

Re: [MOD] Station Mule - Multiple ware station supply

Post by LegionOfOne » Fri, 11. Jan 19, 23:53

Baldamundo wrote:
Fri, 11. Jan 19, 13:52
Btw, does money still get transferred between accounts when all the trades are between player-owned ships and stations?
Not a cent moves in that scenario.
Still a good idea to leave station managers enough cash in the account, they might decide to limit their buy orders otherwise.

daBeschi
Posts: 76
Joined: Mon, 28. Jan 19, 14:04
x4

Re: [MOD] Station Mule - Multiple ware station supply

Post by daBeschi » Fri, 1. Feb 19, 09:41

Hi,

Is it possible to make the mule deliver cargo to a construction camp?

Greetings

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

Re: [MOD] Station Mule - Multiple ware station supply

Post by leecarter » Sun, 3. Feb 19, 00:04

Apparently 1.6 broke this according to a post on the nexus. I'm currently not playing until at least 2.0, maybe 2.5 because the end game basically hits a wall in my opinion. Pulling the mod because I have no interest in it right now.

daBeschi
Posts: 76
Joined: Mon, 28. Jan 19, 14:04
x4

Re: [MOD] Station Mule - Multiple ware station supply

Post by daBeschi » Sun, 3. Feb 19, 09:33

Hi,

Good to know. Thanks for the reply.

Greetings

zebai
Posts: 36
Joined: Wed, 9. May 07, 19:30
x4

Re: [MOD] Station Mule - Multiple ware station supply

Post by zebai » Tue, 5. Feb 19, 16:06

I still use it in 1.6 without issues. It seems to rely heavily on buy orders which means I have to put more money into a station than is strictly required but it works.

The other features on here like seller priority and other check boxes don't really work but the basic without any options still does.

Post Reply

Return to “X4: Foundations - Scripts and Modding”