Vending Machine Export IC10
From Unofficial Stationeers Wiki
This solution will export a given quantity of the specified item from a vending machine.
Contents
[hide]Required Items[edit]
- 1 x Vending Machine
- 1 x Integrated Circuit (IC10)
- 1 x IC Housing
- 1 x Stacker
- 1 x Sorter
- 2 x Logic Memory
- Cables and Chutes
[Expand]Source code: |
---|
Setup[edit]
- Place all components listed above and connect them using Cables and Chutes as shown in the picture. (For cables just connect everything)
- Load the code into the IC and turn everything on
- You may want to put a junction and an inlet to the import of the vending machine so you can restock it.
Usage[edit]
- Set the two memory modules with the quantity and the hash of the item.
- Unless busy, the IC will set the quantity memory to zero and start the export process.
- Excess items will be routed back into the vending machine.
NOTE: The IC can handle split stacks of small quantities in the vending machine or exporting more than one stack. It does NOT handle having insufficient items in the vending machine and will halt until you fill it and export it manually (or reset the whole process)
How It Works[edit]
Main loop[edit]
- Wait until both memory modules have a non-zero value.
- Run device configuration.
- Store request hash and quantity.
- Reset the memory for quantity to indicate the start of the export (and so we don't keep exporting the same item)
- Run the item export function.
_Configuration[edit]
- Configure the sorter for default mode, and the stacker for manual.
_ExportItem[edit]
- Request the item from the vender and wait for it to arrive into the stacker, then run _WaitForDevices to make sure nothing is busy.
- Calculate the setting for the stacker depending on the remaining items, the quantity inside the stacker and the maximum stacking size (in manual mode, it won't do anything until the Output parameter is set to 1)
- Either make another request from the vender, or flush the stacker if it's full.
- Make more requests if there are remaining items, or empty the stacker and route any excess items back into the vender.
_RunStacker[edit]
- Set the output of the sorter, run the stacker and wait for the item to arrive in the sorter.
_WaitForDevices[edit]
- Makes sure none of the devices have occupied import/export slots - the exception being the stacker, since it may have a full processing slot and items stuck in the import slot (for example when the vender exports 30 coal twice in a row. 50 will be in the processing slot and 10 in import.)