Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: How to access a stockpile through scripts?  (Read 359 times)

shrink_tubing

  • Escaped Lunatic
    • View Profile
How to access a stockpile through scripts?
« on: October 07, 2023, 02:55:07 am »

Hi there,

I've been wading through the .xml files for the game and I've found some of the things I wanted in the class declarations for both units and items. Even had some success writing a few basic scripts, which I was quite pleased about, including using some of the methods in the derived classes for items and such.

I have however really struggled with stockpiles. I've done a lot of investigative work in the gui editor in game and discovered that stockpiles will store a list of barrels, bins and wheelbarrows under the item types of BARRELS, BINS and TOOLS. Where those items are specifically assigned to a stockpile for added storage and tool use. It will store their respective x-y coordinates, the individual id of each storage item, and also generates an indexed list for them too.

I also noticed when an item (a bin for example) is lying around un-hauled on the floor if you assign a new bin to a stockpile it seems the class name of the item is appended with a number in angular/diamond brakcets <> corresponding to that stockpile.

For example:

<itembinst etc...>

becomes

<itembinst etc...> <#18>

or something very similar. So that bin gets assigned to stockpile 18 and that's reflected in the appendage to the class name. So I can see some of the mechanics associated with this.

I cannot however find where a stockpile itself is declared as a class. I assume (possibly wrongly) a stockpile is a class which has methods associated with it which one can use to add storage items to it. I've looked through the stockpiles.xml and all I can find are enumaterated types but no stockpile class.

Any ideas as to where I can find the stockpile class (assuming it exists)? Thanks  :)

Logged