Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- buoy = {}
- function buoy:register_buoy(name, def)
- minetest.register_entity(name, {
- hp_max = def.hp_max,
- physical = true,
- collisionbox = def.collisionbox,
- visual = def.visual,
- visual_size = def.visual_size,
- mesh = def.mesh,
- textures = def.textures,
- drawtype = def.drawtype,
- on_rightclick = def.on_rightclick,
- type = def.type,
- sounds = def.sounds,
- animation = def.animation,
- set_animation = function(self, type)
- if not self.animation then
- return
- end
- if not self.animation.current then
- self.animation.current = ""
- end
- if type == "buoy" and self.animation.current ~= "buoy" then
- if
- self.animation.buoy_start
- and self.animation.buoy_end
- and self.animation.speed_normal
- then
- self.object:set_animation(
- {x=self.animation.stand_start,y=self.animation.stand_end},
- self.animation.speed_normal, 0
- )
- self.animation.current = "buoy"
- end
- end
- end,
- })
- end
- buoy:register_buoy({
- resource_name = "buoy:harbour_green",
- type = "npc",
- hp_max = 400000000,
- follow = "default:torch",
- collisionbox = {-0.4, -1, -0.4, 0.4, 0.8, 0.4},
- visual = "mesh",
- mesh = "buoy.x",
- textures = {"buoy_harbour_green.png"},
- visual_size = {x=1,y=1},
- armor = 80,
- drawtype = "front",
- animation = {
- speed_normal = 15,
- buoy_start = 0,
- buoy_end = 40,
- },
- on_rightclick = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
- self.object:remove()
- if puncher and puncher:is_player() then
- puncher:get_inventory():add_item("main", "buoy:harbour_green")
- end
- end,
- })
- minetest.register_craftitem("buoy:harbour_green", {
- description = "Green Harbour Buoy",
- inventory_image = "buoy_harbour_green_inv.png",
- liquids_pointable = true,
- on_place = function(itemstack, placer, pointed_thing)
- if pointed_thing.type ~= "node" then
- return
- end
- pointed_thing.under.y = pointed_thing.under.y + 1
- minetest.env:add_entity(pointed_thing.under, "buoy:harbour_green")
- itemstack:take_item()
- return itemstack
- end,
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement