2018-05-13 16:29:32 -07:00
|
|
|
# Easyvend API
|
2018-05-13 17:17:31 -07:00
|
|
|
Use this API if you want to make an container compatible with vending and
|
2018-05-13 16:29:32 -07:00
|
|
|
depositing machines.
|
|
|
|
|
2018-05-13 17:17:31 -07:00
|
|
|
## How it works
|
|
|
|
|
|
|
|
* Add `easyvend` as optional dependency
|
2018-05-14 16:37:53 -07:00
|
|
|
* Check for existence of `easyvend` mod in code
|
2018-05-13 17:17:31 -07:00
|
|
|
* Call `easyvend.register_chest` for all containers you want to be compatible
|
2018-05-13 16:29:32 -07:00
|
|
|
|
|
|
|
## `easyvend.register_chest = function(node_name, inv_list, meta_owner)`
|
|
|
|
Registers a node (called “chest”) for use with Easyvend. After calling this function,
|
|
|
|
the node will be recognized as storage for vending and depositing machines.
|
|
|
|
|
|
|
|
Easyvend makes the following assumptions about the chest:
|
|
|
|
* It has an inventory
|
|
|
|
* The inventory does not restrict the types of items you can put and take
|
|
|
|
* The chest is owned by a player
|
|
|
|
* The owner is specified in metadata
|
|
|
|
|
|
|
|
### Parameters
|
|
|
|
* `node_name`: Name of the chest node
|
|
|
|
* `inv_list`: Name of the inventory list for exchanging items
|
|
|
|
* `meta_owner`: Identifier of the metadata variable storing the owner name
|
|
|
|
|
|
|
|
### Example
|
2018-05-13 17:17:31 -07:00
|
|
|
|
|
|
|
Register the node `example:superchest` as container:
|
|
|
|
|
2018-05-13 16:29:32 -07:00
|
|
|
```
|
2018-05-13 17:17:31 -07:00
|
|
|
if minetest.get_modpath("easyvend") then
|
|
|
|
easyvend.register_chest("example:superchest", "main", "owner")
|
|
|
|
end
|
2018-05-13 16:29:32 -07:00
|
|
|
```
|
2018-05-13 17:17:31 -07:00
|
|
|
|
2018-05-14 16:37:53 -07:00
|
|
|
The `if` check is a common trick to check for the existence of the `easyvend`
|
2018-05-13 17:17:31 -07:00
|
|
|
and allows you to make the dependency optional.
|