7 local function fireworks_pop(pos)
8 for _,color in pairs(colors) do
9 minetest.add_particlespawner({
14 minvel = vector.new(-16,-16,-16),
15 maxvel = vector.new(16,16,16),
16 minacc = {x=0, y=0, z=0},
17 maxacc = {x=0, y=0, z=0},
22 collisiondetection = false,
23 collision_removal = false,
25 texture = "smoke.png^[colorize:"..color..":255",
28 minetest.sound_play("fireworks_pop",{pos=pos,pitch=math.random(80,100)/100,gain=6.0,max_hear_distance = 128})
32 minetest.register_entity("fireworks:rocket", {
33 initial_properties = {
36 collide_with_objects = false,
37 collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
39 visual_size = {x = 1, y = 1},
40 textures = {"fireworks.png"},
47 on_activate = function(self, staticdata, dtime_s)
48 self.object:set_acceleration(vector.new(0,50,0))
49 minetest.add_particlespawner({
54 minvel = vector.new(0,-20,0),
55 maxvel = vector.new(0,-20,0),
56 minacc = {x=0, y=0, z=0},
57 maxacc = {x=0, y=0, z=0},
62 collisiondetection = false,
63 collision_removal = false,
65 attached = self.object,
66 texture = "smoke.png",
68 minetest.sound_play("fireworks_launch",{object=self.object,pitch=math.random(80,100)/100})
72 on_step = function(self, dtime)
73 self.timer = self.timer + dtime
74 if self.timer >= 1 then
75 fireworks_pop(self.object:get_pos())
82 minetest.register_craftitem("fireworks:rocket", {
83 description = "Fireworks",
84 inventory_image = "fireworks.png",
85 wield_image = "fireworks.png",
86 on_place = function(itemstack, placer, pointed_thing)
87 if not pointed_thing.type == "node" then
91 minetest.add_entity(pointed_thing.above, "fireworks:rocket")
99 minetest.register_craft({
101 output = "fireworks:rocket",
102 recipe = {"main:paper","mob:gunpowder"},