Dwarf Fortress > DF Modding

Is there a DFHack script to merge stacks or the contents of barrels?

(1/6) > >>

kane_t:
I've found myself in a situation where I have a barrel full of single strawberries or plump helmets, which my brewer then turns into multiple barrels each containing 5 units of alcohol.  It's a bit of a waste.  Seems like if a hauler brings a barrel with 5 units of strawberry wine to a stockpile with another barrel containing 5 units of strawberry wine, they should just pour the contents into the existing barrel and leave the one they were carrying empty.

I was thinking of trying to make a script that just checks if there are multiple barrels of the same kind of alcohol in a stockpile and, if so, merges their contents up to some sensible maximum, by removing the contents of one barrel and just marking up the stack size in another barrel.  Or, solving the problem on the other end by just looking at a single barrel (of fruit, in this case) and merging the stacks within it (so all my strawberries [2] become a single strawberries [26]). 

But this seems like such an obvious problem, I figured somebody must have already made a script or plugin to do it.  Does anybody know of such a plugin?  I tried looking around but haven't been able to find anything.

Arx:
None mentioned in the readme or the most recent thread, so I guess not. It might be some kind of horribly thorny problem though.

milo christiansen:
It's a kinda hard problem to solve, how do you decide which items to merge?

kane_t:

--- Quote from: milo christiansen on June 17, 2015, 12:03:25 pm ---It's a kinda hard problem to solve, how do you decide which items to merge?

--- End quote ---

Well, the simplest solution would be to just leave control up to the user.  Have them select an item in a container, and merge any items of the same type in the stockpile into it up to a maximum stack size (and container capacity).  There are already scripts that work on the selected item, you could just c/p that functionality.

The more complex, automated approach would be to, whenever a dwarf stores a container in a stockpile, for each element in the container, search the stockpile for a stack of that item of less than maximum size in a container which isn't full and, if found, merge into the other container up until the maximum stack size or container capacity.  Continue until either all the items in the stack have been moved out of the barrel, or there are no valid destinations for merging, then move on to the next element of the container.

I took a quick look at the data structure for stockpiles in dfhack, and it looks like stack size is just an int you could increment, and you can iterate the contents of a stockpile pretty easily.  The only complication I can see is whether it's possible (or desirable) to straight-up remove an item from a container.  How well the game handles something like that.

milo christiansen:
Doing it automatically could kill fps with large stockpiles, this would need testing. Manually would be possible, even fairly easy, but would be a lot of micro management to make it really effective.

Annother option is to make a "stacker" workshop, as long as the workshop is powered it will take an item from it's inputs (using the Rubble powered workshop API, which is the easiest system available for making automated workshops) and try to stack it up to a user settable limit using other items at it's inputs. This would be easy to do, but I don't have much time right now, so we will see.

Navigation

[0] Message Index

[#] Next page

Go to full version