Advertisement
Guest User

Buoy code broken

a guest
Sep 11th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.06 KB | None | 0 0
  1. buoy = {}
  2. function buoy:register_buoy(name, def)
  3.     minetest.register_entity(name, {
  4.         hp_max = def.hp_max,
  5.         physical = true,
  6.         collisionbox = def.collisionbox,
  7.         visual = def.visual,
  8.         visual_size = def.visual_size,
  9.         mesh = def.mesh,
  10.         textures = def.textures,
  11.         drawtype = def.drawtype,
  12.         on_rightclick = def.on_rightclick,
  13.         type = def.type,
  14.         sounds = def.sounds,
  15.         animation = def.animation,
  16.  
  17.         set_animation = function(self, type)
  18.             if not self.animation then
  19.                 return
  20.             end
  21.             if not self.animation.current then
  22.                 self.animation.current = ""
  23.             end
  24.             if type == "buoy" and self.animation.current ~= "buoy" then
  25.                 if
  26.                     self.animation.buoy_start
  27.                     and self.animation.buoy_end
  28.                     and self.animation.speed_normal
  29.                 then
  30.                     self.object:set_animation(
  31.                         {x=self.animation.stand_start,y=self.animation.stand_end},
  32.                         self.animation.speed_normal, 0
  33.                     )
  34.                     self.animation.current = "buoy"
  35.                 end
  36.             end
  37.         end,
  38.  
  39.     })
  40. end
  41.  
  42. buoy:register_buoy({
  43.     resource_name = "buoy:harbour_green",
  44.     type = "npc",
  45.     hp_max = 400000000,
  46.     follow = "default:torch",
  47.     collisionbox = {-0.4, -1, -0.4, 0.4, 0.8, 0.4},
  48.     visual = "mesh",
  49.     mesh = "buoy.x",
  50.     textures = {"buoy_harbour_green.png"},
  51.     visual_size = {x=1,y=1},
  52.     armor = 80,
  53.     drawtype = "front",
  54.     animation = {
  55.         speed_normal = 15,
  56.         buoy_start = 0,
  57.         buoy_end = 40,
  58.     },
  59.         on_rightclick = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
  60.         self.object:remove()
  61.         if puncher and puncher:is_player() then
  62.             puncher:get_inventory():add_item("main", "buoy:harbour_green")
  63.         end
  64.     end,
  65. })
  66.  
  67. minetest.register_craftitem("buoy:harbour_green", {
  68.     description = "Green Harbour Buoy",
  69.     inventory_image = "buoy_harbour_green_inv.png",
  70.     liquids_pointable = true,
  71.         on_place = function(itemstack, placer, pointed_thing)
  72.             if pointed_thing.type ~= "node" then
  73.                 return
  74.             end
  75.             pointed_thing.under.y = pointed_thing.under.y + 1
  76.             minetest.env:add_entity(pointed_thing.under, "buoy:harbour_green")
  77.             itemstack:take_item()
  78.             return itemstack
  79.         end,
  80. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement