Implement anvil inventory slot restrictions
[MineClone/MineClone2.git] / mods / ITEMS / mcl_anvils / init.lua
blob070e8abd9b4f82b20a12589f930338415c86c8b8
1 local anvildef = {
2 groups = {pickaxey=1, falling_node=1, crush_after_fall=1, deco_block=1, anvil=1},
3 tiles = {"mcl_anvils_anvil_top_damaged_0.png^[transformR90", "mcl_anvils_anvil_base.png", "mcl_anvils_anvil_side.png"},
4 paramtype = "light",
5 sunlight_propagates = true,
6 is_ground_content = false,
7 paramtype2 = "facedir",
8 drawtype = "nodebox",
9 node_box = {
10 type = "fixed",
11 fixed = {
12 {-8/16, 2/16, -5/16, 8/16, 8/16, 5/16}, -- top
13 {-6/16, -4/16, -1/16, 6/16, 5/16, 1/16}, -- middle
14 {-8/16, -8/16, -5/16, 8/16, -4/16, 5/16}, -- base
17 sounds = mcl_sounds.node_sound_metal_defaults(),
18 _mcl_blast_resistance = 6000,
19 _mcl_hardness = 5,
20 allow_metadata_inventory_put = function(pos, listname, index, stack, player)
21 if listname == "output" then
22 return 0
23 else
24 return stack:get_count()
25 end
26 end,
27 allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
28 if to_list == "output" then
29 return 0
30 else
31 return count
32 end
33 end,
34 on_construct = function(pos)
35 local meta = minetest.get_meta(pos)
36 local inv = meta:get_inventory()
37 inv:set_size("input", 2)
38 inv:set_size("output", 1)
39 local form = "size[9,8.75]"..
40 "background[-0.19,-0.25;9.41,9.49;mcl_anvils_inventory.png]"..
41 mcl_vars.inventory_header..
42 "list[current_player;main;0,4.5;9,3;9]"..
43 "list[current_player;main;0,7.74;9,1;]"..
44 "list[context;input;1,2.5;1,1;]"..
45 "list[context;input;4,2.5;1,1;1]"..
46 "list[context;output;8,2.5;1,1;]"..
47 "listring[context;output]"..
48 "listring[current_player;main]"..
49 "listring[context;input]"..
50 "listring[current_player;main]"
51 meta:set_string("formspec", form)
52 end,
54 if minetest.get_modpath("screwdriver") then
55 anvildef.on_rotate = screwdriver.rotate_simple
56 end
58 local anvildef0 = table.copy(anvildef)
59 anvildef0.description = "Anvil"
61 local anvildef1 = table.copy(anvildef)
62 anvildef1.description = "Slightly Damaged Anvil"
63 anvildef1.groups.not_in_creative_inventory = 1
64 anvildef1._doc_items_create_entry = false
65 anvildef1.tiles = {"mcl_anvils_anvil_top_damaged_1.png^[transformR90", "mcl_anvils_anvil_base.png", "mcl_anvils_anvil_side.png"}
67 local anvildef2 = table.copy(anvildef)
68 anvildef2.description = "Very Damaged Anvil"
69 anvildef2.groups.not_in_creative_inventory = 1
70 anvildef2._doc_items_create_entry = false
71 anvildef2.tiles = {"mcl_anvils_anvil_top_damaged_2.png^[transformR90", "mcl_anvils_anvil_base.png", "mcl_anvils_anvil_side.png"}
73 minetest.register_node("mcl_anvils:anvil", anvildef0)
74 minetest.register_node("mcl_anvils:anvil_damage_1", anvildef1)
75 minetest.register_node("mcl_anvils:anvil_damage_2", anvildef2)
77 minetest.register_craft({
78 output = "mcl_anvils:anvil",
79 recipe = {
80 { "mcl_core:ironblock", "mcl_core:ironblock", "mcl_core:ironblock" },
81 { "", "mcl_core:iron_ingot", "" },
82 { "mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot" },
86 dofile(minetest.get_modpath(minetest.get_current_modname()).."/falling_anvil.lua")