Advertisement
Guest User

Untitled

a guest
Jan 24th, 2018
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.70 KB | None | 0 0
  1. minetest.register_node("my_garage_door:garage_door", {
  2.     description = "Garage Door",
  3.     tiles = {
  4.         "default_snow.png"
  5.     },
  6.     drawtype = "nodebox",
  7.     paramtype = "light",
  8.     paramtype2 = "facedir",
  9.     groups = {cracky=3},
  10.     node_box = {
  11.         type = "fixed",
  12.         fixed = {
  13.             {-1.5, -0.5, -0.125, 1.5, 0.5, -0.0625},
  14.             {-1.5, -0.5, -0.1875, 1.5, -0.3125, -0.0625},
  15.             {-1.5, -0.25, -0.1875, 1.5, -0.0624999, -0.0625},
  16.             {-1.5, 0, -0.1875, 1.5, 0.1875, -0.0625},
  17.             {-1.5, 0.25, -0.1875, 1.5, 0.4375, -0.0625},
  18.         }
  19.     },
  20.     selection_box = {
  21.         type = "fixed",
  22.         fixed = {
  23.             {-1.5, -0.5, -0.1875, 1.5, 1.5, -0.0625},
  24.         }
  25.     },
  26.     on_place = function(itemstack, placer, pointed_thing)
  27.     local p = pointed_thing.above
  28.     local p2 = minetest.dir_to_facedir(placer:get_look_dir())
  29. print(p2)
  30.         minetest.set_node(p, {name = "my_garage_door:garage_door",param2 = p2})
  31.         minetest.set_node({x=p.x,y=p.y+1,z=p.z}, {name = "my_garage_door:garage_door_top",param2 = p2})
  32.     end,
  33.     after_destruct = function(pos, oldnode)
  34.         minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "air"})
  35.     end,
  36.    
  37.     on_rightclick = function(pos, node, player, itemstack, pointed_thing)
  38.     local p2 = node.param2 --minetest.dir_to_facedir(player:get_look_dir())
  39.     local t1 = {x=pos.x,y=pos.y+1,z=pos.z}
  40.     local t2 = {x=pos.x,y=pos.y+1,z=pos.z}
  41.         if p2 == 0 then
  42.         t1 = {x=pos.x,y=pos.y+1,z=pos.z+1}
  43.         t2 = {x=pos.x,y=pos.y+1,z=pos.z+2}
  44.         elseif p2 == 1 then
  45.         t1 = {x=pos.x+1,y=pos.y+1,z=pos.z}
  46.         t2 = {x=pos.x+2,y=pos.y+1,z=pos.z}
  47.         elseif p2 == 2 then
  48.         t1 = {x=pos.x,y=pos.y+1,z=pos.z-1}
  49.         t2 = {x=pos.x,y=pos.y+1,z=pos.z-2}
  50.         elseif p2 == 3 then
  51.         t1 = {x=pos.x-1,y=pos.y+1,z=pos.z}
  52.         t2 = {x=pos.x-2,y=pos.y+1,z=pos.z}
  53.         end
  54.             minetest.set_node(t1,{name="my_garage_door:garage_door_open",param2=p2})
  55.             minetest.set_node(t2,{name="my_garage_door:garage_door_open2",param2=p2})
  56.             minetest.set_node(pos,{name="air"})
  57.             minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="air"})
  58.         --end
  59.     end,
  60. })
  61. minetest.register_node("my_garage_door:garage_door_top", {
  62.     tiles = {
  63.         "default_snow.png"
  64.     },
  65.     drawtype = "nodebox",
  66.     paramtype = "light",
  67.     paramtype2= "facedir",
  68.     drop = "",
  69.     diggable = false,
  70.     pointable = false,
  71.     groups = {cracky=3},
  72.     node_box = {
  73.         type = "fixed",
  74.         fixed = {
  75.             {-1.5, -0.5, -0.125, 1.5, 0.5, -0.0625},
  76.             {-1.5, -0.5, -0.1875, 1.5, -0.3125, -0.0625},
  77.             {-1.5, -0.25, -0.1875, 1.5, -0.0624999, -0.0625},
  78.             {-1.5, 0, -0.1875, 1.5, 0.1875, -0.0625},
  79.             {-1.5, 0.25, -0.1875, 1.5, 0.4375, -0.0625},
  80.         }
  81.     },
  82.     selection_box = {type = "fixed",fixed = {{0, 0, 0, 0, 0, 0},}},
  83. })
  84. minetest.register_node("my_garage_door:garage_door_open", {
  85.     tiles = {
  86.         "default_snow.png"
  87.     },
  88.     drawtype = "nodebox",
  89.     paramtype = "light",
  90.     paramtype2= "facedir",
  91.     drop = "my_garage_door:garage_door",
  92.     diggable = false,
  93.     groups = {cracky=3},
  94.     node_box = {
  95.         type = "fixed",
  96.         fixed = {
  97.             {-1.5, 0.4375, -0.5, 1.5, 0.375, 0.5},
  98.             {-1.5, 0.375, 0.3125, 1.5, 0.5, 0.5},
  99.             {-1.5, 0.375, 0.0625, 1.5, 0.5, 0.25},
  100.             {-1.5, 0.375, -0.1875, 1.5, 0.5, 0},
  101.             {-1.5, 0.375, -0.4375, 1.5, 0.5, -0.25},
  102.         }
  103.     },
  104.     selection_box = {type = "fixed",fixed = {{-1.5, 0.375, -0.5, 1.5, 0.5, 1.5},}},
  105.    
  106.     on_rightclick = function(pos, node, player, itemstack, pointed_thing)
  107.     local p2 = node.param2 --minetest.dir_to_facedir(player:get_look_dir())
  108.     local t1 = {x=pos.x,y=pos.y+1,z=pos.z}
  109.     local t2 = {x=pos.x,y=pos.y+1,z=pos.z}
  110.         if p2 == 0 then
  111.         t1 = {x=pos.x,y=pos.y,z=pos.z-1}
  112.         t2 = {x=pos.x,y=pos.y-1,z=pos.z-1}
  113.         t3 = {x=pos.x,y=pos.y,z=pos.z+1}
  114.         elseif p2 == 1 then
  115.         t1 = {x=pos.x-1,y=pos.y,z=pos.z}
  116.         t2 = {x=pos.x-1,y=pos.y-1,z=pos.z}
  117.         t3 = {x=pos.x+1,y=pos.y,z=pos.z}
  118.         elseif p2 == 2 then
  119.         t1 = {x=pos.x,y=pos.y,z=pos.z+1}
  120.         t2 = {x=pos.x,y=pos.y-1,z=pos.z+1}
  121.         t3 = {x=pos.x,y=pos.y,z=pos.z-1}
  122.         elseif p2 == 3 then
  123.         t1 = {x=pos.x+1,y=pos.y,z=pos.z}
  124.         t2 = {x=pos.x+1,y=pos.y-1,z=pos.z}
  125.         t3 = {x=pos.x-1,y=pos.y,z=pos.z}
  126.         end
  127.             minetest.set_node(t1,{name="my_garage_door:garage_door_top",param2=p2})
  128.             minetest.set_node(t2,{name="my_garage_door:garage_door",param2=p2})
  129.             minetest.set_node(pos,{name="air"})
  130.             minetest.set_node(t3,{name="air"})
  131.     end,
  132. })
  133. minetest.register_node("my_garage_door:garage_door_open2", {
  134.     tiles = {
  135.         "default_snow.png"
  136.     },
  137.     drawtype = "nodebox",
  138.     paramtype = "light",
  139.     paramtype2= "facedir",
  140.     drop = "",
  141.     diggable = false,
  142.     pointable = false,
  143.     groups = {cracky=3},
  144.     node_box = {
  145.         type = "fixed",
  146.         fixed = {
  147.             {-1.5, 0.4375, -0.5, 1.5, 0.375, 0.5},
  148.             {-1.5, 0.375, 0.3125, 1.5, 0.5, 0.5},
  149.             {-1.5, 0.375, 0.0625, 1.5, 0.5, 0.25},
  150.             {-1.5, 0.375, -0.1875, 1.5, 0.5, 0},
  151.             {-1.5, 0.375, -0.4375, 1.5, 0.5, -0.25},
  152.         }
  153.     },
  154.     selection_box = {type = "fixed",fixed = {{0, 0, 0, 0, 0, 0},}},
  155.  
  156. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement