From 379a4e591144a2bdd60484e1e29873a9f19bac99 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 14 May 2018 02:17:31 +0200 Subject: [PATCH] Make default dependency officially optional --- API.md | 18 +++++++++++++++--- README.md | 10 ++++++++-- depends.txt | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/API.md b/API.md index e1addc4..39b1969 100644 --- a/API.md +++ b/API.md @@ -1,8 +1,12 @@ # Easyvend API -Use this API if you want to make an comntainer compatible with vending and +Use this API if you want to make an container compatible with vending and depositing machines. -The API only has one function: +## How it works + +* Add `easyvend` as optional dependency +* Check for existance of `easyvend` mod in code +* Call `easyvend.register_chest` for all containers you want to be compatible ## `easyvend.register_chest = function(node_name, inv_list, meta_owner)` Registers a node (called “chest”) for use with Easyvend. After calling this function, @@ -20,6 +24,14 @@ Easyvend makes the following assumptions about the chest: * `meta_owner`: Identifier of the metadata variable storing the owner name ### Example + +Register the node `example:superchest` as container: + ``` -easyvend.register_chest("example:superchest", "main", "owner") +if minetest.get_modpath("easyvend") then + easyvend.register_chest("example:superchest", "main", "owner") +end ``` + +The `if` check is a common trick to check for the existance of the `easyvend` +and allows you to make the dependency optional. diff --git a/README.md b/README.md index 8464215..c1824c0 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,14 @@ Version: 0.4.3 Adds vending and depositing machines which allow to buy and sell items from other players. +## Requirements +Runs natively in Minetest Game. + +May also run in other games if they have the `default` mod and locked chest +(`default:chest_locked`). + +Locked chests from other mods are not supported, but mods can choose +to add support for Easyvend on their own (see developer information below). ## How to use Help is also included as help entry for Item Documentation [`doc_items`]. @@ -24,8 +32,6 @@ But it can be changed via the setting `easyvend_currency`. - - ## Appendix ### Developer information If you want to a container node compatible with vending/depositing machines, diff --git a/depends.txt b/depends.txt index c800511..e9558c0 100644 --- a/depends.txt +++ b/depends.txt @@ -1,4 +1,4 @@ -default +default? screwdriver? doc? doc_items? -- 2.11.4.GIT