Happy Fourth of July :)

This commit is contained in:
oilboi 2020-07-04 07:47:49 -04:00
parent 1e65fbf6f3
commit 83b192b0d7
7 changed files with 104 additions and 0 deletions

103
mods/fireworks/init.lua Normal file
View File

@ -0,0 +1,103 @@
local colors ={
"red",
"white",
"blue"
}
local function fireworks_pop(pos)
for _,color in pairs(colors) do
minetest.add_particlespawner({
amount = 15,
time = 0.001,
minpos = pos,
maxpos = pos,
minvel = vector.new(-16,-16,-16),
maxvel = vector.new(16,16,16),
minacc = {x=0, y=0, z=0},
maxacc = {x=0, y=0, z=0},
minexptime = 1.1,
maxexptime = 1.5,
minsize = 1,
maxsize = 2,
collisiondetection = false,
collision_removal = false,
vertical = false,
texture = "smoke.png^[colorize:"..color..":255",
})
end
minetest.sound_play("fireworks_pop",{pos=pos,pitch=math.random(80,100)/100})
end
minetest.register_entity("fireworks:rocket", {
initial_properties = {
hp_max = 1,
physical = true,
collide_with_objects = false,
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
visual = "sprite",
visual_size = {x = 1, y = 1},
textures = {"fireworks.png"},
is_visible = true,
pointable = true,
},
timer = 0,
on_activate = function(self, staticdata, dtime_s)
self.object:set_acceleration(vector.new(0,50,0))
minetest.add_particlespawner({
amount = 30,
time = 1,
minpos = pos,
maxpos = pos,
minvel = vector.new(0,-20,0),
maxvel = vector.new(0,-20,0),
minacc = {x=0, y=0, z=0},
maxacc = {x=0, y=0, z=0},
minexptime = 1.1,
maxexptime = 1.5,
minsize = 1,
maxsize = 2,
collisiondetection = false,
collision_removal = false,
vertical = false,
attached = self.object,
texture = "smoke.png",
})
minetest.sound_play("fireworks_launch",{object=self.object,pitch=math.random(80,100)/100})
end,
sound_played = false,
on_step = function(self, dtime)
self.timer = self.timer + dtime
if self.timer >= 1 then
fireworks_pop(self.object:get_pos())
self.object:remove()
end
end,
})
minetest.register_craftitem("fireworks:rocket", {
description = "Fireworks",
inventory_image = "fireworks.png",
wield_image = "fireworks.png",
on_place = function(itemstack, placer, pointed_thing)
if not pointed_thing.type == "node" then
return
end
minetest.add_entity(pointed_thing.above, "fireworks:rocket")
itemstack:take_item()
return itemstack
end,
})
minetest.register_craft({
type = "shapeless",
output = "fireworks:rocket",
recipe = {"main:paper","mob:gunpowder"},
})

View File

@ -0,0 +1 @@
all sounds: https://freesound.org/people/j1987/sounds/140728/ cc0

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 642 B