Added Fireworks
This commit is contained in:
parent
696d8e8636
commit
0dc5701d9b
@ -7,6 +7,7 @@ I should just start giving updates a version number to avoid naming updates.
|
||||
- Added various new sounds
|
||||
- Give Fire an animated texture
|
||||
- Added a Sky Dimension for people using `floatlands` mapgen setting in v7
|
||||
- Added Fireworks!
|
||||
|
||||
## [Oct 20th - Nov 2nd] Update: The Something Update
|
||||
|
||||
|
@ -303,3 +303,11 @@ function PyuTest.get_inventory_drops(pos, inventory, drops)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
PyuTest.drop_item = function (pos, name)
|
||||
local o = minetest.add_item(pos, name)
|
||||
|
||||
if o then
|
||||
o:add_velocity(vector.new(math.random(-2, 2), 5, math.random(-2, 2)))
|
||||
end
|
||||
end
|
||||
|
@ -259,11 +259,7 @@ PyuTest.make_mob = function (name, properties, options)
|
||||
local pos = self.object:get_pos()
|
||||
|
||||
for _, v in pairs(self.options.drops) do
|
||||
local o = minetest.add_item(pos, v)
|
||||
|
||||
if o then
|
||||
o:add_velocity(vector.new(math.random(-2, 2), 5, math.random(-2, 2)))
|
||||
end
|
||||
PyuTest.drop_item(pos, v)
|
||||
end
|
||||
end
|
||||
}, {__index = class}))
|
||||
|
84
mods/ENTITIES/pyutest_fireworks/init.lua
Normal file
84
mods/ENTITIES/pyutest_fireworks/init.lua
Normal file
@ -0,0 +1,84 @@
|
||||
minetest.register_entity("pyutest_fireworks:firework", {
|
||||
initial_properties = {
|
||||
visual = "upright_sprite",
|
||||
textures = {"pyutest-firework.png", "pyutest-firework.png"},
|
||||
physical = true
|
||||
},
|
||||
|
||||
on_activate = function (self)
|
||||
self.object:set_velocity(vector.new(0, 10, 0))
|
||||
end,
|
||||
|
||||
on_step = function (self, dtime)
|
||||
local vel = self.object:get_velocity()
|
||||
if vel.y < 0 then
|
||||
self:explode()
|
||||
self.object:remove()
|
||||
end
|
||||
|
||||
vel.y = vel.y - (2 * dtime)
|
||||
self.object:set_velocity(vel)
|
||||
self:trail()
|
||||
end,
|
||||
|
||||
trail = function (self)
|
||||
local pos = self.object:get_pos()
|
||||
|
||||
minetest.add_particle({
|
||||
pos = pos,
|
||||
size = 2,
|
||||
expirationtime = 0.2,
|
||||
glow = minetest.LIGHT_MAX,
|
||||
vertical = true,
|
||||
texture = "pyutest-firework-blast.png"
|
||||
})
|
||||
end,
|
||||
|
||||
explode = function (self)
|
||||
local color = {
|
||||
r = math.random(50, 255),
|
||||
g = math.random(50, 255),
|
||||
b = math.random(50, 255),
|
||||
}
|
||||
local texture = string.format("pyutest-firework-blast.png^[colorize:%s", minetest.colorspec_to_colorstring(color))
|
||||
|
||||
local pos = self.object:get_pos()
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = math.random(20, 40),
|
||||
time = 1.8,
|
||||
minexptime = 0.4,
|
||||
maxexptime = 1.4,
|
||||
minsize = 2,
|
||||
maxsize = 2,
|
||||
vertical = false,
|
||||
glow = minetest.LIGHT_MAX,
|
||||
|
||||
collisiondetection = false,
|
||||
texture = texture,
|
||||
minpos = pos,
|
||||
maxpos = pos,
|
||||
minvel = vector.new(-6, -6, -6),
|
||||
maxvel = vector.new( 6, 6, 6),
|
||||
})
|
||||
|
||||
minetest.sound_play({
|
||||
name = "block_break",
|
||||
gain = 3,
|
||||
}, {
|
||||
pos = pos
|
||||
})
|
||||
end
|
||||
})
|
||||
|
||||
PyuTest.make_item("pyutest_fireworks:firework", "Firework", {}, "pyutest-firework.png", {
|
||||
on_place = function (itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type == "node" then
|
||||
local pos = pointed_thing.above
|
||||
minetest.add_entity(pos, "pyutest_fireworks:firework")
|
||||
itemstack:take_item()
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
})
|
1
mods/ENTITIES/pyutest_fireworks/mod.conf
Normal file
1
mods/ENTITIES/pyutest_fireworks/mod.conf
Normal file
@ -0,0 +1 @@
|
||||
depends = pyutest_tools
|
@ -27,6 +27,22 @@ PyuTest.make_grass = function (name, desc, groups, color, ttex, stex, dtex, econ
|
||||
},
|
||||
type = "shapeless"
|
||||
})
|
||||
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {name.."_block"},
|
||||
sidelen = 16,
|
||||
fill_ratio = 0.048,
|
||||
decoration = name.."_plant"
|
||||
})
|
||||
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = {name.."_block"},
|
||||
sidelen = 16,
|
||||
fill_ratio = 0.022,
|
||||
decoration = name.."_fern"
|
||||
})
|
||||
end
|
||||
|
||||
PyuTest.make_grass("pyutest_grass:grass", "Grass", {
|
||||
|
BIN
textures/pyutest-firework-blast.png
Normal file
BIN
textures/pyutest-firework-blast.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 78 B |
BIN
textures/pyutest-firework.png
Normal file
BIN
textures/pyutest-firework.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 154 B |
Loading…
x
Reference in New Issue
Block a user