[Mod] Fireworks [fireworks]

User avatar
InfinityProject
Member
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

[Mod] Fireworks [fireworks]

by InfinityProject » Post

The idea came from here: http://minetest.net/forum/viewtopic.php ... 489#p48489

Fireworks are cool right? Well I'm adding them to minetest. Here, have a screenshot:

[img=Fireworks]https://dl.dropbox.com/u/82668184/screenshot_3631640.png[/img]

What this mod does is when the fireworks are punched, the fire part appears in the sky and disappears in a few seconds.

Crafting w = wood and t = torch r = red fireworks b = blue y = yellow
Red Fireworks
www
wtw
www

Blue Fireworks
r

Yellow Fireworks
b

The rest are shapeless (can be crafted in any order.)
Orange Fireworks
r y

Green Fireworks
b y

Purple Fireworks
r b

Rainbow Fireworks

Just craft all of the colors together for 5 rainbow fireworks!

Download v0.3 (latest)
Download v0.2
Download v0.1

Changelog:
v0.1 Initial release
v0.2 Fireworks look more realistic, added blue.
v0.3 Fireworks now spawn in random locations in the sky, added orange, yellow, green, purple, and rainbow.

License: WTFPL
Depends: default
Last edited by InfinityProject on Sun Nov 04, 2012 15:21, edited 1 time in total.

cornernote
Member
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Post

this is a really cool idea! Hey, any chance you could use the particles mod to make the fire parts? that would look sweet if it shot up into the air, then exploded into colours of light that then die just before they hit the ground.

User avatar
InfinityProject
Member
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Post

That would look freaking awesome! Can your particles just be activated when a node is dug? Or can they be used for this purpose?

Josh
Member
Posts: 1146
Joined: Fri Jun 29, 2012 23:11
Location: Victoria, Australia

by Josh » Post

Intresting mod :)

cornernote
Member
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Post

You'd probably have to just copy some code from particles into your mod. I dont think its worth depending on particles.

Have a look here:
https://github.com/cornernote/minetest- ... s/init.lua

Change this:

Code: Select all

minetest.register_on_dignode(function(pos, oldnode, digger)
To this:

Code: Select all

fireworks.explode(function()
You'll have to do a bit more than that inside the function, but once that is working, you can call fireworks.explode() to make your fireworks particles.

You may also find it useful to see older versions of particles mod, it was less complex to understand in earlier versions:

initial version: https://github.com/cornernote/minetest- ... 81d1ae689a

version before pilzadam's overhaul: https://github.com/cornernote/minetest- ... 2a907c2001

mauvebic
Member
Posts: 1550
Joined: Fri Jan 27, 2012 11:32

by mauvebic » Post

would be nicer more round :-)

Code: Select all

for x=-radius,radius do
for y=-radius,radius do
for z=-radius,radius do
   if x*x+y*y+z*z <= radius*radius then
      add_particle({x=pos.x+x,y=pos.y+y,z=pos.z+z}) end
end
end
end
though is each particle it's own entity? might lag :-/
Last edited by mauvebic on Tue Oct 23, 2012 03:38, edited 1 time in total.

cornernote
Member
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Post

i think they should all start in the middle (about 100-200 of them), and explode outwards with great velocity, and gravity, then die after about 1-3 seconds.

User avatar
InfinityProject
Member
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Post

Now, I am no good at all with entities so creating them would not be easy for me. Is there a way to perhaps just spawn the particles when the fireworks node is punched?

Also mauvebic I would love to use that somehow.

mauvebic
Member
Posts: 1550
Joined: Fri Jan 27, 2012 11:32

by mauvebic » Post

this is the relevant bit you need:

Code: Select all

local radius = 6 -- feel free to change this
for x=-radius,radius do
for y=-radius,radius do
for z=-radius,radius do
   if x*x+y*y+z*z <= radius*radius then
      minetest.env:add_node({x=pos.x+x,y=pos.y+y,z=pos.z+z},{name='fireworks:node'}) end
end
end
end
thats it. just check the nodename and the radius you want and you should be good 2 go :-) the codes already wtfpl
Last edited by mauvebic on Wed Oct 24, 2012 02:15, edited 1 time in total.

User avatar
InfinityProject
Member
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Post

V0.2 Coming soon
[img=fireworks2]https://dl.dropbox.com/u/82668184/screenshot_85123323.png[/img]
Edit: 800th post!
Last edited by InfinityProject on Wed Oct 24, 2012 23:48, edited 1 time in total.

mauvebic
Member
Posts: 1550
Joined: Fri Jan 27, 2012 11:32

by mauvebic » Post

Wow, that looks like the real deal :-) +1

User avatar
InfinityProject
Member
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Post

Thanks. I changed the node's drawtype to plantlike. It's actually amazing how good it looks. I want Corenernote's particles to kind of fall to the ground when the node disappears. Also I'm adding sound and blue fireworks.
Last edited by InfinityProject on Thu Oct 25, 2012 01:30, edited 1 time in total.

User avatar
InfinityProject
Member
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Post

[img=Fireworks blue]https://dl.dropbox.com/u/82668184/screenshot_92310120.png[/img]

cornernote
Member
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Post

that looks awesome! are you using nodes, or entities (register_node or register_entity)?

would love to see the current code so i can have a fiddle

User avatar
InfinityProject
Member
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Post

Nodes,

Code: Select all

function fireworks_activate (pos, node)
if 
  node.name == "fireworks:firework_red" 
then
local radius = 4 
for x=-radius,radius do
for y=-radius,radius do
for z=-radius,radius do
   if x*x+y*y+z*z <= radius*radius then
      minetest.env:add_node({x=pos.x+x,y=pos.y+y,z=pos.z+z},{name='fireworks:red'}) end
end
end
end
minetest.sound_play("fireworks.ogg",
    {pos = pos, gain = 1.0, max_hear_distance = 32,})
elseif
  node.name == "fireworks:firework_blue" 
then
local radius = 4 
for x=-radius,radius do
for y=-radius,radius do
for z=-radius,radius do
   if x*x+y*y+z*z <= radius*radius then
      minetest.env:add_node({x=pos.x+x,y=pos.y+y,z=pos.z+z},{name='fireworks:blue'}) end
end
end
end
minetest.sound_play("fireworks.ogg",
    {pos = pos, gain = 1.0, max_hear_distance = 32,})
end
end
minetest.register_on_punchnode(fireworks_activate)

cornernote
Member
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Post

it seems...
in order to make them move, they have to be entities.
in order to make them light, they have to be nodes.

=(

User avatar
InfinityProject
Member
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Post

What I want definately is for the fireworks to launch into the air and then explode. Could the node change into an entity and turn back to a node when it has hit a position? Say y+8

cornernote
Member
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Post

minetest.env:remove_node()
minetest.env:add_entity()

then in the onstep of the entity, after a timer expires, do the opposite.

User avatar
VanessaE
Moderator
Posts: 4655
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaE
Location: Western NC
Contact:

by VanessaE » Post

Suggestion for the light issue: Register entities for the sparks so they can move, but also register a single "light node" with light level set to maximum, and place a whole bunch of them in a more or less spherical formation. Give that node fully transparent (e.g. empty) textures so that it isn't actually visible. Then delete them randomly as the sparks dissipate.
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)

User avatar
InfinityProject
Member
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Post

Will look into that Vanessa.

Mod updated.

mauvebic
Member
Posts: 1550
Joined: Fri Jan 27, 2012 11:32

by mauvebic » Post

You can remove the nodes by generating a sphere of air from the same pos with the same radius, from your fireworks function using minetest.after(10,function() <--code--> end) Otherwise you could register them as falling nodes?

Please avoid entities, you'll inhibit your players ability to fire multiple fireworks at once, generating a sphere of nodes is consuming enough for most CPUs. Besides, it already looks quite nice :-)
Last edited by mauvebic on Fri Oct 26, 2012 03:44, edited 1 time in total.

User avatar
InfinityProject
Member
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Post

I had tried falling nodes but it didn't look very good. Why not keep the abm? It works well.

User avatar
Neuromancer
Member
Posts: 958
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

by Neuromancer » Post

This is a really cool mod.

I created some sound effects for you, and made it so they blow up in the air in random locations.
-You need to hit R to enable full viewing range to see them.
-place a bunch of red and a blue & red fireworks on the ground near enough so you can click them
-left click them in rapid succession and look up.

http://ompldr.org/vZzI2Zg

Tried this hooked up to my stereo system with some serious bass. The sounds got waaay better.
Note: I found a bug where if you left clicked on any node it would activate the firework. This has been fixed in the download above.

Does anyone have an idea on how to make the fireworks disappear faster? And/or to make them give off bright flashes of light or just more light?
Last edited by Neuromancer on Mon Oct 29, 2012 00:26, edited 1 time in total.

User avatar
InfinityProject
Member
Posts: 1009
Joined: Sat Mar 17, 2012 00:52
Location: World of Infinity, US

by InfinityProject » Post

Nice neuromancer! Ill add that in next version. I'm gonna add green, yellow, purple, and rainbow. I will also attempt mesecon compatibility.

Jordach
Member
Posts: 4534
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach
Location: Blender Scene

by Jordach » Post

This means that mesecon clocks can be used!

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests