Space Engineers

Space Engineers

Not enough ratings
Automated Market
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
402.556 KB
3 Mar, 2021 @ 9:04am
22 Mar, 2021 @ 5:17pm
3 Change Notes ( view )

Subscribe to download
Automated Market

Description
What is this?

This script automatically checks your inventories, and publishes buy/sell requests to one or more store blocks in order to maintain a target level of stock.

While it is still very basic, it gets the job done well enough to be worthy of being put up here.

How to set this up

Hardware required

- One programmable block with this script running
- One or more Store blocks with the autoMarketTag value in their name (case sensitive, by default [AUTOMARKET])
- Zero or more containers for storage

Configuring the script

Simply insert new TargetEntries in the autoMarketCommodities list.

The script will automatically read your grid's inventory (without peeking into connected grids) and publish buy/sell requests accordingly in all the store blocks with the autoMarketTag in their name.

Target entries have the following signature:
TargetEntry(String name, String type, int targetQuantity, int pricePerUnit)

Feel free to modify this script to your liking
19 Comments
greendragonsegg 12 Jun, 2023 @ 1:29pm 
Love the script, i was able to translate it to english, would you be ok if i uploaded it? with the link to yours? also did you ever figure out how to use the blocks custom data to store price lists vs lists inside the script itself?
TheOnePunisher 22 May, 2023 @ 5:29am 
@Marcvs101: Basically I'd want the script to keep track of the items in my trading station inventory and keep them u for sale until the stock runs out then put back up when it's replenished.

Same thing for items I want to buy, I'd like to have the different prices for buying and selling too. The more I look into the store block the more I find out how painfully limited it is.
TheOnePunisher 22 May, 2023 @ 5:26am 
@Marcvs101: Thanks for the response...erm....would you be up to doing this? I'm too old/dumb to lean how to script. :P
Marcvs101  [author] 22 May, 2023 @ 3:35am 
@TheOnePunisher Sure! From what I remember I used one list (or dictionary) to keep track of items, price and desired amount.
You could freely modify this structure to allow for buy and sell prices, as well as buy and sell amounts. The logic checks that use this data should not be complicated.
Be aware that Space Engineers forces a minimum price for each item, and be also aware that this minimum price is not documented, so the function will just throw an error if you set something too low.
The quantity of the sold items should already reflect the quantity of these items in the inventories.
The idea is that you are telling the station to "only keep N of that item in your inventory", so if you have N+10, the station will try to sell 10. If you set N = 0, the station will try to sell all of its stock.
Marcvs101  [author] 22 May, 2023 @ 3:34am 
@Viper Unfortunately scripts are very picky with the names of the items.. I had a hard time too trying to find good documentation.

@maximeg80 That might be difficult to do for me, as I would need to add a new (programmable) block to each station, loaded up with the configured script.. Sorry

@acheaen Originally the script was coded to look for all the store blocks with a certain name, put them in a list and then apply all market operations on the stores of that list. If you want to split what is bought or sold at different stores, you could either run a second script, using a different store name, or you could edit the script to work with multiple store names.
It is not an ideal solution, but this script was cobbled up quickly.
TheOnePunisher 21 May, 2023 @ 8:01pm 
Can the script be edited to allow for different prices when creating buys and sells? Also could it make the quantity to sell tied to the quantity of the resource on the station/ship?
acheaen 26 Jan, 2023 @ 9:04pm 
Any way to incorporate multiple store blocks so I can split up what is being bought or sold at different store blocks
maximeg80 8 Mar, 2022 @ 11:32am 
Hi, do you think you could create a mod to add your script to NPC station as the "NPC Defense Shields Provider" do with shield?
Viper 5 Aug, 2021 @ 11:17pm 
i got ores and componets to list just fine but the tools throw a exception when i try to list those. thanks loving the script so far.
Marcvs101  [author] 1 May, 2021 @ 10:40am 
@Airomis, that would be really nice
Unfortunately Space Engineers puts a minimum price for all commodities.. This means that trying to sell uranium at 1 SC will result in the market block throwing an error.

In addition, I haven't been able to find any reference to this minimum price on the scripting API, this means that the only way of finding this lower bound is through tiral and error .