|
1 | 1 | -- Minetest 0.4 mod: vessels
|
2 | 2 | -- See README.txt for licensing and other information.
|
3 | 3 |
|
| 4 | +local vessels_shelf_formspec = |
| 5 | + "size[8,7;]".. |
| 6 | + default.gui_bg.. |
| 7 | + default.gui_bg_img.. |
| 8 | + default.gui_slots.. |
| 9 | + "list[context;vessels;0,0.3;8,2;]".. |
| 10 | + "list[current_player;main;0,2.85;8,1;]".. |
| 11 | + "list[current_player;main;0,4.08;8,3;8]".. |
| 12 | + default.get_hotbar_bg(0,2.85) |
| 13 | + |
| 14 | +minetest.register_node("vessels:shelf", { |
| 15 | + description = "Vessels shelf", |
| 16 | + tiles = {"default_wood.png", "default_wood.png", "default_wood.png^vessels_shelf.png"}, |
| 17 | + is_ground_content = false, |
| 18 | + groups = {choppy=3,oddly_breakable_by_hand=2,flammable=3}, |
| 19 | + sounds = default.node_sound_wood_defaults(), |
| 20 | + |
| 21 | + on_construct = function(pos) |
| 22 | + local meta = minetest.get_meta(pos) |
| 23 | + meta:set_string("formspec", vessels_shelf_formspec) |
| 24 | + local inv = meta:get_inventory() |
| 25 | + inv:set_size("vessels", 8*2) |
| 26 | + end, |
| 27 | + can_dig = function(pos,player) |
| 28 | + local meta = minetest.get_meta(pos); |
| 29 | + local inv = meta:get_inventory() |
| 30 | + return inv:is_empty("vessels") |
| 31 | + end, |
| 32 | + |
| 33 | + allow_metadata_inventory_put = function(pos, listname, index, stack, player) |
| 34 | + local meta = minetest.get_meta(pos) |
| 35 | + local inv = meta:get_inventory() |
| 36 | + local to_stack = inv:get_stack(listname, index) |
| 37 | + if listname == "vessels" then |
| 38 | + if minetest.get_item_group(stack:get_name(), "vessel") ~= 0 |
| 39 | + and to_stack:is_empty() then |
| 40 | + return 1 |
| 41 | + else |
| 42 | + return 0 |
| 43 | + end |
| 44 | + end |
| 45 | + end, |
| 46 | + |
| 47 | + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) |
| 48 | + local meta = minetest.get_meta(pos) |
| 49 | + local inv = meta:get_inventory() |
| 50 | + local stack = inv:get_stack(from_list, from_index) |
| 51 | + local to_stack = inv:get_stack(to_list, to_index) |
| 52 | + if to_list == "vessels" then |
| 53 | + if minetest.get_item_group(stack:get_name(), "vessel") ~= 0 |
| 54 | + and to_stack:is_empty() then |
| 55 | + return 1 |
| 56 | + else |
| 57 | + return 0 |
| 58 | + end |
| 59 | + end |
| 60 | + end, |
| 61 | + |
| 62 | + on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) |
| 63 | + minetest.log("action", player:get_player_name().. |
| 64 | + " moves stuff in vessels shelf at "..minetest.pos_to_string(pos)) |
| 65 | + end, |
| 66 | + on_metadata_inventory_put = function(pos, listname, index, stack, player) |
| 67 | + minetest.log("action", player:get_player_name().. |
| 68 | + " moves stuff to vessels shelf at "..minetest.pos_to_string(pos)) |
| 69 | + end, |
| 70 | + on_metadata_inventory_take = function(pos, listname, index, stack, player) |
| 71 | + minetest.log("action", player:get_player_name().. |
| 72 | + " takes stuff from vessels shelf at "..minetest.pos_to_string(pos)) |
| 73 | + end, |
| 74 | +}) |
| 75 | + |
| 76 | +minetest.register_craft({ |
| 77 | + output = 'vessels:shelf', |
| 78 | + recipe = { |
| 79 | + {'group:wood', 'group:wood', 'group:wood'}, |
| 80 | + {'group:vessel', 'group:vessel', 'group:vessel'}, |
| 81 | + {'group:wood', 'group:wood', 'group:wood'}, |
| 82 | + } |
| 83 | +}) |
| 84 | + |
4 | 85 | minetest.register_node("vessels:glass_bottle", {
|
5 | 86 | description = "Glass Bottle (empty)",
|
6 | 87 | drawtype = "plantlike",
|
|
0 commit comments