Clarify “Access denied.” message
[minetest_easyvend.git] / init.lua
blob7e5a3548ef6d120a8ee9900b518f995537992ef8
1 ---
2 --easyvend
3 --Copyright (C) 2012 Bad_Command, 2016 Wuzzy
4 --
5 --This library is free software; you can redistribute it and/or
6 --modify it under the terms of the GNU Lesser General Public
7 --License as published by the Free Software Foundation; either
8 --version 2.1 of the License, or (at your option) any later version.
9 --
10 --This program is distributed in the hope that it will be useful,
11 --but WITHOUT ANY WARRANTY; without even the implied warranty of
12 --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 --GNU General Public License for more details.
15 --You should have received a copy of the GNU Lesser General Public
16 --License along with this library; if not, write to the Free Software
17 --Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 ---
20 easyvend = {}
21 easyvend.VERSION = {}
22 easyvend.VERSION.MAJOR = 1
23 easyvend.VERSION.MINOR = 0
24 easyvend.VERSION.PATCH = 0
25 easyvend.VERSION.STRING = easyvend.VERSION.MAJOR .. "." .. easyvend.VERSION.MINOR .. "." .. easyvend.VERSION.PATCH
27 dofile(minetest.get_modpath("easyvend") .. "/easyvend.lua")
29 local sounds
30 local soundsplus = {
31 place = { name = "easyvend_disable", gain = 1 },
32 dug = { name = "easyvend_disable", gain = 1 }, }
33 if minetest.get_modpath("default") ~= nil then
34 sounds = default.node_sound_wood_defaults(soundsplus)
35 else
36 sounds = soundsplus
37 end
39 local machine_template = {
40 paramtype2 = "facedir",
41 groups = {choppy=2,oddly_breakable_by_hand=2},
43 after_place_node = easyvend.after_place_node,
44 can_dig = easyvend.can_dig,
45 on_receive_fields = easyvend.on_receive_fields,
46 sounds = sounds,
48 allow_metadata_inventory_put = easyvend.allow_metadata_inventory_put,
49 allow_metadata_inventory_take = easyvend.allow_metadata_inventory_take,
50 allow_metadata_inventory_move = easyvend.allow_metadata_inventory_move,
51 on_punch = easyvend.machine_check,
54 local vendor_on = table.copy(machine_template)
55 vendor_on.description = "Vending Machine"
56 vendor_on.tile_images ={"easyvend_vendor_side.png", "easyvend_vendor_bottom.png", "easyvend_vendor_side.png",
57 "easyvend_vendor_side.png", "easyvend_vendor_side.png", "easyvend_vendor_front_on.png"}
58 vendor_on.groups.not_in_creative_inventory = 1
59 vendor_on.groups.not_in_doc = 1
60 vendor_on.drop = "easyvend:vendor"
62 local vendor_off = table.copy(machine_template)
63 vendor_off.description = vendor_on.description
64 vendor_off.tile_images = table.copy(vendor_on.tile_images)
65 vendor_off.tile_images[6] = "easyvend_vendor_front_off.png"
67 local depositor_on = table.copy(machine_template)
68 depositor_on.description = "Depositing Machine"
69 depositor_on.tile_images ={"easyvend_depositor_side.png", "easyvend_depositor_bottom.png", "easyvend_depositor_side.png",
70 "easyvend_depositor_side.png", "easyvend_depositor_side.png", "easyvend_depositor_front_on.png"}
71 depositor_on.groups.not_in_creative_inventory = 1
72 depositor_on.groups.not_in_doc = 1
73 depositor_on.drop = "easyvend:depositor"
75 local depositor_off = table.copy(machine_template)
76 depositor_off.description = depositor_on.description
77 depositor_off.tile_images = table.copy(depositor_on.tile_images)
78 depositor_off.tile_images[6] = "easyvend_depositor_front_off.png"
80 minetest.register_node("easyvend:vendor", vendor_off)
81 minetest.register_node("easyvend:vendor_on", vendor_on)
82 minetest.register_node("easyvend:depositor", depositor_off)
83 minetest.register_node("easyvend:depositor_on", depositor_on)
85 if minetest.get_modpath("default") ~= nil then
86 minetest.register_craft({
87 output = 'easyvend:vendor',
88 recipe = {
89 {'group:wood', 'group:wood', 'group:wood'},
90 {'group:wood', 'default:steel_ingot', 'group:wood'},
91 {'group:wood', 'default:steel_ingot', 'group:wood'},
95 minetest.register_craft({
96 output = 'easyvend:depositor',
97 recipe = {
98 {'group:wood', 'default:steel_ingot', 'group:wood'},
99 {'group:wood', 'default:steel_ingot', 'group:wood'},
100 {'group:wood', 'group:wood', 'group:wood'},
105 if minetest.get_modpath("doc_items") ~= nil then
106 doc.add_entry_alias("nodes", "easyvend:vendor", "easyvend:vendor_on")
107 doc.add_entry_alias("nodes", "easyvend:depositor", "easyvend:depositor_on")
108 doc.sub.items.set_items_longdesc({
109 ["easyvend:vendor"] = "A vending machine allows its owner to offer a certain item in exchange for gold ingots. The users can pay with gold ingots and will get the item or items in return.",
110 ["easyvend:depositor"] = "A depositing machine allows its owner to offer gold ingots in exchange for a certain item. The users can supply the depositing machine with the requested item and will get gold ingots in return.",
112 doc.sub.items.set_items_usagehelp({
113 ["easyvend:vendor"] = "For customers: The vending machine has to be ready to be used. If the green LED lights up, it is ready. Point the vending machine to see its owner and what it has to offer and at which price (item count first). Rightclick the vending machine to open the buying menu. You will pay with the number of items shown at “Price” and you will get the item at “Offered item” in return. Click on “Buy” to buy this offer once, repeat this as often as you like.\nFor owners: First, place a locked chest and fill it with the item you want to sell, make sure you leave some inventory slots empty for the gold ingots. Place the vending machine directly on top of the locked chest. Rightclick the machine. Set the offered item by moving an item from your invenory into the slot. The price item can not be changed. Now set the number of items per sale and their price and click on “Confirm” to confirm. Check the message and status for any errors. If the status is “Ready.”, the machine works properly. All other status messages are errors. The earnings of the vending machine can be retrieved from the locked chest.",
115 ["easyvend:depositor"] = "For users: The depositing machine has to be ready to be used. If the green LED lights up, it is ready. Point the depositing machine to see its owner and what item it asks for and at which payment (item count first). Rightclick the depositing machine to open the selling menu. You will pay with the number of items shown at “Requested item” and you will get the items at “Payment” in return. Click on “Sell” to exchange items, repeat this as often as you like.\nFor owners: First, place a locked chest and supply it with gold ingots, make sure you leave some inventory slots empty for the items you want to retrieve. Place the depositing machine directly on top of the locked chest. Rightclick the machine. Set the requested item by moving an item from your invenory into the slot. The payment item can not be changed. Now set the number of requested items and their price and click on “Confirm” to confirm. Check the message and status for any errors. If the status is “Ready.”, the machine works properly, all other status messages are errors. The deposited items can be retrieved from the locked chest.",