Prioritize Stockpiles

will be nce if we can set a number on stockpiles
so for exemple i have a mason building with a little stockpile next to it with only stone selected
then when i give it a number like #1 the workers will restock the pile from a other one like a bigger one
so that the mason worker dont need to walk far to get stone


I’d definitely like some more control over my stockpiles. So I’d like to add the idea of temporary/transport stockpiles, which could possibly be done the same way. For example: While clear-cutting a forest, my Hearthlings bring logs to a nearby stockpile. Other Hearthlings, and them once they’re done, can bring the logs to a more permanent place. This saves a lot of time and uses larger villages more effectively.


Good idea. There is a way to do that right now: you could set the bigger stockpile to not stock the object you want to move, thus causing your Hearthlings to bring the desired object to the next closest stockpile that stocks this object.

You’re right, though, it is a good idea. Doing what I suggested is a bit of a dirty solution, and gets out of hand quickly when the number of stockpiles goes up.

I love this idea. Having several regional “sorting stations” where everything goes temporarily for inventory and re-routing purposes sounds like an awesome idea. Might come in VERY handy when it comes to setting up far away mining camps and the like.


it would also be helpful if you have a mining camp far away, you could set up a temporary food stockpile, thus your hearthlings wouldn’t have to march all the way back to your town to get food.


For the last days I have been playing this more frequently and I find it kinda annoying that I can’t manage my stockpiles.

I’ve came up with some options to help you do just that (but I have no idea if it is hard to code)

  1. I would love to have a option to have stockpiles feed into one another, so that my hearthlings would be able to keep a set or a minimum number of items in a stockpile at most times.

The main use for this was that I can keep my craft’s men/woman supplied with all the materials they need near them and that they wont run around all the time to get the stuff they need

  1. Bulk storage. This is a storage type that is only used to store items that can’t be placed elsewhere and if there is room somewhere then a hearthling will get the item.

  2. Maybe even a new class named stockpile manger that gets faster and faster when he/she levels up and also can take more (of the same sort) items with him/her if he/she levels up.
    Also an idea for leveling him/her up, is XP for distance he/she has run with items (see it as strength training)

I did found a topic with a somewhat similar problem but that was to prioritize it and not manage it

1 Like

Stockpile management is something that will need to be looked at in the future. As it stands right now, it is acceptable, but will proceed to steadily worsen as more and more things are added to the game. Worry not, there will be improvements!

I was mainly curious about point one, and I think that you may be asking for something a little different. I think you are wanting to be able to have stockpiles feed into one another, so that you could setup a large storehouse for wood, then setup a stockpile near your smithy for your blacksmith to take from, and tell it to take wood from the big one? This makes a little more sense to me, rather than having you set stockpile amounts per item type per stockpile.

1 Like

that is a way better explanation of what i tried to tell in point 1.
thanks for that ill adjust it (if it is possible).

and yes i know it is good for what it is right now, I just wanted to suggest a better system so that they will look in it and maybe change it.

im pretty sure there is already a thread for this… will try and find it.

edit: here it is,

@Relyss could merge perhaps?

1 Like

It would be really nice if we could somehow assign stockpiles to maintain certain items. For example, I might want a stockpile near trees to collect fallen wood, but a more permanent storage pile in my warehouse. So if we could assign maintain resource x I could simply tell my warehouse to maintain enough to be full and hopefully my workers would move the wood from the woodcamp stockpile to the warehouse stockpile until it was full. It would also be nice to do theis to maintain small amounts of food stockpiles in houses. This would also be nice to be able to tell the farmer Maintain x flowers, or x turnips or whatever. We could still setup our turnip fields or whatever, but the farmer would only plant them if we needed them in the stockpile. If you cant do this in hte stockpile itself, maybe have a ledger or something craftable that we can assign to a stockpile. Maybe make a Farmers shed or somehting like the carpenters stump.

I would like to setup a small stockpile by a carpenter for wood, and another small stockpile by the workbench for output, so that the carpenter doesn’t have to walk all that far.
The problem is that the small stockpiles empty/fill, and the carpenter ends up walking all the way to the main stockpile anyway.

It would be nice to say that certain stockpiles were able to be set to fill (keep full, even if you have to pull from other stockpiles), hold (current behavior), or send (if there is any other stockpile that accepts this stuff, move it on) behavior.

This would allow a better managed logistics system, which will be needed once further production chains begin to come into existence, and free the expert tradies from unneeded hauling duties.

that’s good idea. maybe settings to stockpiles that you can choise. "this stockpile is important/less important/normal
or like that settings. so if you set one stockpile to important, your workers keep it full, and less important, your workers fill it after important stockpiles is full, normal, just like now all stockpiles.

The problem is that you’re thinking backwards. Or rather, the game does it backwards. Instead of an item searching for a stockpile to go, it’s actually stockpiles that search items to be refilled. That makes it easier (by always taking the closest item to a stockpile, rather than searching the closest stockpile for every item - you’ll likely have less stockpiles than items) to manage code and performance wise, but does kind of disallow any sort of priorisation.

It’s not impossible to change that (for example, stockpiles could constantly search for items, keep that list, maybe even create a lease on the item), but it would require some thinking.


So it currently works just like sorting clothes then? Whenever I put away clothes, the closet always searches for any nearby and orders me to get them.

What? You mean that doesn’t happen for you?


What’d be an interesting feature to see would be if you could specify which stockpile you want materials to go to when you give a harvest or mining command. Maybe this could even be extended to assigning stockpiles to entire zones, such as farming, trapping grounds, and pastures (which could also get reassigned after creation).

Of course, that doesn’t necessarily solve the problem of dropped items. Maybe a tab can get placed on the collected item (visible and changeable by the player in the GUI), retaining its intended destination unless otherwise specified? I’m not sure how intensive such a system would be for the game–do any of you code masters have an idea? I assume it wouldn’t retain the pathfinding, only the destination entity’s name/info. Destruction of the destination should result in the removal of the tab, leaving an item open for general, unspecified collection and storage.

Personally, I wouldn’t mind being able to set destinations for crafting orders too (and assigning stockpiles to workstations), but that does run the risk of becoming too excessive with management. The issue of course is keeping the input stockpile filled with the necessary resources and materials for crafting.

1 Like

Like I’ve said, you’re currently looking at this the wrong way around. Items don’t search for stockpiles. Stockpiles search for items. Think of it as some sort of pathfinding liquid: It spreads evenly out from a stockpile and every item it touches is checked for its availability (“Do my filters match this entity?”). If it does, the worker will carry this item to the stockpile - so only after it was decided which item is to be carried, it’s actually figuring out the way from the item to the stockpile.

That makes a lot of sense, as I’ve said above. Imagine you have 3 stockpiles but a hundred items. Three stockpiles searching for items equals three pathfinders doing work. If the items were to search a stockpile, we had a hundred different pathfinders doing different pathfindings - which would be infeasible.

So: Items do not have a destination. Stockpiles are really just greedy bastards with a first-come-first-taken mentality. That makes it difficult to have any sort of priorisation done.

Example: Let’s say we have two stockpiles, Lefty and Righty. And an item.

Let’s say that lefty has a high priority of 6, and righty a low priority of 1. They both could stock the oak log.

With the current system, there’s no way to determine in which stockpile the log will end up in. Because whatever stockpile’s pathfinder first registers the oak log will claim the log for itself. That could be lefty. That could be righty.

So how could a priority system work? It’s difficult. It can’t work this way, but let’s assume that both pathfinders were running at the same time and with the same speed. Obviously, righty would find the log first, because it’s closer. Lefty has no chance to even say “Hey, that log is more important to me”, because by the time it finds the log, it’s already claimed by righty. The pathfinder does, for obvious reason, ignore entities that have been claimed, so the log is not considered a valid entity for lefty.

There’s a possible fix, which is even semi-nice. It’s a radical change from what we have currently, however, and it might even improve performance a lot, assuming a few things are done properly in the engine/game:

A service would take care and keep track of stockpiles (and items). Whenever an item is dropped onto the ground, the service will check some frames later if the item is still unreserved (to avoid messing with entities that are picked up immediately/soonish). If it is, it’s checking the item against all stockpiles, creating a list of stockpiles that could fit this item. This does not involve any pathfinding at all; it’s a simple check which stockpiles could be considered.

Once it has the list, we could start sorting it. For example, by stockpile priority. Or stockpile priority / air distance. Or whatever heuristic might seems appropriate. That way, we would end up with one stockpile that has “won” the census by being the most appropriate one.

If there was no eligible stockpile, the item could be added to a “reserve list”. Whenever any stockpile is modified or one is removed/added, every entity in the reserve list is considered to be “dropped” again, therefore querying all stockpiles again.

At this point, we have both a stockpile (the destination) and the item that needs to go there. We can now tweak the AI even further by doing a BFS-search from the item and find the closest (free) worker to move the entity. This has the advantage that hearthlings no longer run across the whole map when there’s somebody closer by; because it would always pick the closest worker.

So what we would gain:

  • Customizable stockpiles: Priorities, quantities and all these things could become possible, even on an per-entity basis (i.e. fine chairs have a priority of 100, normal chairs are not stocked). By plugging lua into this, you could have filters and priorities that are as fine as you want them to be. It would also be possible to have “roundabouts” stockpiles; i.e. “I take oak logs with priority 100 until I have 20 of them; then I don’t take any more”.
  • Customizable items: This whole process could be a bidirectional thing. Stockpiles filter and prioritise themselves, but the item can pick too. For example, you could define a region and everything inside that region is taken to stockpile X, no matter what the stockpiles themselves want (for example, have all stuff from your mines put into some intermediary stockpile at the entrance to avoid hearthlings running across the whole town because there’s a designated stockpile elsewhere). This picks up @Atralane’s idea of tagging items.
  • Improved performance: Because there is no continuous pathfinding involved anymore, the game can use these resources for other things.
  • Improved AI: Items are taken by the closest worker, not the one whose PF found it first. Therefore, we’re reducing the overall walking and standing around in odd places.

This is based on some assumptions:

  • There is a proper callback to find out when an entity was dropped into the world. One can trace the terrain’s entity_container to find out when children have been added, which could work. However, workbenches do not add the items to the terrain but rather the workbench, and the PF can/is doing recursive searches; so our service would need to do that too (i.e. instead of just tracing the terrain, it needs to trace every workbench too, and every other entity that can act as container).
  • The stockpile components need to inform the service whenever a filter is changed. If the filter is expanded (i.e. less entities types may be stocked), all now unfitting entities must be reported as “dropped”. If the filter is reduced, the service must check if there are reserve entities that could be stocked. The same applies to removing/adding stockpiles.
  • For the closest-AI approach, there would have to be a way to find out if a worker was currently “idle”. I suppose there could be, because you could simply check for idle actions (i.e. if your current action descends from stonehearth:idle). There would also need to be a way to dispatch tasks to entities directly. I suppose that’s all stuff the task scheduler does, so in the very worst case that could be recycled.

It sounds like fun to do, actually.


This was entirely too much fun to read! Thank you for this gem.

Would it be possible to add some stacking functionality to stockpiles? Whether visibly stacked or not, such that one tile holds 2+ logs, for example. 1 item per tile takes up a lot of prime real estate, imo.

1 Like

[quote=“Valnus, post:17, topic:10594”]
Would it be possible to add some stacking functionality to stockpiles? Whether visibly stacked or not, such that one tile holds 2+ logs, for example. 1 item per tile takes up a lot of prime real estate, imo.
[/quote]this kind o’ stuff has been discussed in other places, will try to find em later.

Found one :slight_smile:

1 Like

and thus i realize how insufficient i am…