Minetest Barrels Mod
Compatible with minetest 0.4.10+
This mod provides barrels that can hold any quantity of a single item. There is a normal barrel, a locked barrel that is usable only by the owner, and a shop barrel which (if the currency mod is installed) provides a simple and easy to use way of selling items.
Left-clicking a barrel removes one item from the barrel. With shift (or whatever is defined as 'sneak') a whole stack is removed. Right-clicking the barrel places the held item(s) in it, if they're the right type of item.
To see the contents of a barrel, simply point at it and the item, count and (if relevant) the owner will be displayed on the HUD.
Requirements
Optional dependencies:
- currency - my fork. Only needed if you want use shop barrels.
- pipeworks - my fork
- digilines - my fork
Optionally, if you want debug logging support, use:
- moddebug - https://gitlab.com/CiaranG/moddebug
Shop barrel
Punching the barrel allows any player to buy items in the set quantity and price.
Any combination of currency notes can be placed in the 'pay here' area. Clicking 'buy' brings out the right number of items for the player to remove to their inventory, and the money is taken (with change being given as necessary).
Right-clicking the barrel has the same effect, except for the owner where it behaves like a normal barrel, allowing them to add stock.
On the buy form, the owner will also have a 'Manage' button, which brings up an additional form where they can set the number of units sold at a time, and the price, and also remove any money earned.
By combining shop barrels with pipeworks and digilines support (and other mods for transport/manufacture/harvest) a fully automated self-replenishing shop can be constructed.
Other barrel mod
There's an old mod very similar to this, called 'barrels' (this one is 'barrel'). If you've previously used that, you can convert everything over to this mod by setting this in your minetest.conf:
barrel_convert_old=true
Aside from the cleaner codebase and better features in this version, switching will provide better server, client and network performance and is recommended.
Pipeworks support
Items can be added to the barrel via the top, bottom or back.
Items are sent out from the bottom of the barrel in response to an appropriate digilines message. Note that locked and shop barrels do not provide protection against pipe removal. This is by design - use an area protection mod if you need to prevent that.
Digilines support
Barrels respond to messages received on the "barrel' channel. The message must be a table, with "action" and "item" fields. Action is one of:
- "send" - instruct the barrel to send items. The "item" field should be one or more item/count pairs - examples: "default:cobble 4" or "default:stone 1 default:dirt 1". Any barrel that contains one of the items listed will send that many items (or as many as it has, if it doesn't have enough) down the pipeworks connection to the bottom of the barrel.
- "count" - the "item" field shoud be a single item name, e.g. "default:cobble". Any barrel containing that item will response with a message on the "barrelcount" channel, with the message being a table containing two fields, "item" (the item name) and "count" (the number of that item in the barrel.
API
There are some API functions to allow use of barrels by other modules. A working example of this can be found in the people mod, where NPC entities can, for example, use shop barrels to buy and sell goods in the same way as a player.
License
License: Code - LGPL, Textures - WTFPL