diff options
author | Zefram <zefram@fysh.org> | 2014-07-15 00:52:33 +0100 |
---|---|---|
committer | Zefram <zefram@fysh.org> | 2014-07-15 00:52:33 +0100 |
commit | aee9f7e6d682e91a20958d16c192baa6dce6c2e4 (patch) | |
tree | d1dbb0f74a568af97c6a9da177ba05811f8dabd4 /trashcan.lua | |
parent | 571d1d45ee6dd4bb4cb635351d7d9d8099dea0e5 (diff) |
Add trash can
The trash can can be used either manually (via form) or at the end of
a pipe. It destroys whatever is placed in it.
Diffstat (limited to 'trashcan.lua')
-rw-r--r-- | trashcan.lua | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/trashcan.lua b/trashcan.lua new file mode 100644 index 0000000..880ab59 --- /dev/null +++ b/trashcan.lua @@ -0,0 +1,51 @@ +minetest.register_node("pipeworks:trashcan", { + description = "Trash Can", + drawtype = "normal", + tiles = { + "pipeworks_trashcan_bottom.png", + "pipeworks_trashcan_bottom.png", + "pipeworks_trashcan_side.png", + "pipeworks_trashcan_side.png", + "pipeworks_trashcan_side.png", + "pipeworks_trashcan_side.png", + }, + groups = { snappy = 3, tubedevice = 1, tubedevice_receiver = 1 }, + tube = { + insert_object = function(pos, node, stack, direction) + return ItemStack("") + end, + can_insert = function(pos, node, stack, direction) + return true + end, + connect_sides = { left = 1, right = 1, front = 1, back = 1, top = 1, bottom = 1 }, + }, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", + "size[8,7]".. + "item_image[0,0;1,1;pipeworks:trashcan]".. + "label[1,0;Trash Can]".. + "list[current_name;trash;3.5,1;1,1;]".. + "list[current_player;main;0,3;8,4;]") + meta:set_string("infotext", "Trash Can") + meta:get_inventory():set_size("trash", 1) + end, + after_place_node = function(pos) + pipeworks.scan_for_tube_objects(pos) + end, + after_dig_node = function(pos) + pipeworks.scan_for_tube_objects(pos) + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.get_meta(pos):get_inventory():set_stack(listname, index, ItemStack("")) + end, +}) + +minetest.register_craft({ + output = "pipeworks:trashcan", + recipe = { + { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }, + { "default:steel_ingot", "", "default:steel_ingot" }, + { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }, + }, +}) |