Install this package:
$ jget get vatm
vatm
This is an improved "visual" version of my original ATM package (thus vatm
)
It is not a complete solution by itself - you need to provide an adaptor to get information from the storage system and actuate withdrawals & deposits. It exposes the standard ATM API, used in atm
, vatm
and mvatm
Usage
The ATM needs a connection to an item storage system. There are three methods you need to overwrite to enable this functionality:
List(self)
- should return a table, mapping item names to quantities.
Deposit(self)
- should actuate a deposit. It should block until the deposit is complete - or at least, in progress.
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.