Advertisement
Guest User

Minetest gates mod

a guest
Sep 3rd, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.58 KB | None | 0 0
  1. -- gates edit of xdoors by GloopMaster
  2. -- gates nodebox by splizard
  3.  
  4. minetest.register_node("gates:gate_wood", {
  5.     drawtype = "nodebox",
  6.     tile_images = {"default_wood.png"},
  7.     paramtype = "light",
  8.     paramtype2 = "facedir",
  9.     is_ground_content = true,
  10.     sunlight_propagates = true,
  11.     groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
  12.     drop = "gates:gate_wood",
  13.     node_box = {
  14.         type = "fixed",
  15.         fixed = {
  16.             {-0.5, -0.15, -0.06, -0.25, 0.4, 0.06},  
  17.             {0.25, -0.15, -0.06, 0.5, 0.4, 0.06},  
  18.             {-0.125, 0, -0.06, 0.125, 0.25, 0.06},  
  19.             {-0.25, 0.25, -0.06, 0.25, 0.4, 0.06},
  20.             {0.25, 0, -0.06, -0.25, -0.15, 0.06},  
  21.             {0, 1.0, -0.1, 0.5, 1.0, -0.0999},
  22.             {0, 1.0, 0.0999, 0.5, 1.0, 0.1}
  23.         }
  24.     },
  25.     selection_box = {
  26.         type = "fixed",
  27.         fixed = {
  28.             {-0.5, -0.5, -0.06, 0.5, 0.5, 0.06},
  29.         },
  30.     },
  31.     on_punch = function(pos, node, puncher)
  32.         --Gate always opens away from the player
  33.         if node.param2 then
  34.             local playerpos = puncher:getpos()
  35.             local dir = {x = pos.x - playerpos.x, y = pos.y - playerpos.y, z = pos.z - playerpos.z}
  36.             local param = minetest.dir_to_facedir(dir)
  37.             if node.param2 == 0 and param == 2 then node.param2 = 2 end
  38.             if node.param2 == 2 and param == 0 then node.param2 = 0 end
  39.             if node.param2 == 1 and param == 3 then node.param2 = 3 end
  40.             if node.param2 == 3 and param == 1 then node.param2 = 1 end
  41.         end
  42.         minetest.env:add_node(pos, {name = "gates:gate_wood_open", param2=node.param2})
  43.     end
  44. })
  45.  
  46. minetest.register_node("gates:gate_wood_open", {
  47.     drawtype = "nodebox",
  48.     tile_images = {"default_wood.png"},
  49.     paramtype = "light",
  50.     paramtype2 = "facedir",
  51.     is_ground_content = true,
  52.     groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
  53.     drop = "gates:gate_wood",
  54.     sunlight_propagates = true,
  55.     node_box = {
  56.         type = "fixed",
  57.         fixed = {
  58.             --Left
  59.             {-0.5, -0.15, -0.06, -0.4, 0.4,  0.19},  
  60.             {-0.5,  0,     0.34, -0.4, 0.25, 0.50},  
  61.             {-0.5,  0.25,  0.19, -0.4, 0.4,  0.50},
  62.             {-0.5, -0.15,  0.19, -0.4, 0,    0.50},  
  63.            
  64.             --Right
  65.             {0.4, -0.15, -0.06, 0.5, 0.4,  0.19},  
  66.             {0.4,  0,     0.34, 0.5, 0.25, 0.50},  
  67.             {0.4,  0.25,  0.19, 0.5, 0.4,  0.50},  
  68.             {0.4, -0.15,  0.19, 0.5, 0,    0.50},  
  69.         }
  70.     },
  71.     selection_box = {
  72.         type = "fixed",
  73.         fixed = {
  74.             {-0.5, -0.5, -0.06, 0.5, 0.5, 0.06},
  75.         },
  76.     },
  77.     on_punch = function(pos, node, puncher)
  78.         minetest.env:add_node(pos, {name = "gates:gate_wood"})
  79.     end
  80. })
  81.  
  82.  
  83. minetest.register_craft({
  84.     output = 'gates:gate_wood',
  85.     recipe = {
  86.         { 'default:stick', 'default:wood', 'default:stick' },
  87.         { 'default:stick', 'default:wood', 'default:stick' },
  88.     },
  89. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement