Install this package:
$ jget get atm
atm
This package provides a convenient, text-based interface for dealing with an item storage system.
It is not a complete solution by itself - you need to provide an adaptor to get information from the storage system and actuate withdrawals.
Usage
The ATM provides three functions, and there are three corresponding methods you need to overwrite to enable this functionality.
getList(self)
- should return a table, mapping item names to quantities.
getCount(self, item)
- should return the count of the item provided
withdraw(self, item, amount)
- should withdraw <amount>
of <item>
(i.e. place that much in the output inventory). The function should return the actual amount withdrawn, as it is intended to be best-effort. If you cannot fulfil the order in its' entirety, you should withdraw as much as possible.
You provide these functions by passing in an object with those functions defined on it (see the example below).
Example:
If this code confuses you, I recommend checking out the Lua reference manual entry on OOP.
gay rights!