Mining Particles (Sections of a texture particles)

Mining Particles (Sections of a texture particles)

Postby Oil_boi » Sun Apr 07, 2019 3:43 pm

So I recreated the sections of particles that the game engine uses, but in lua. Basically this example creates a poof of particles when you mine a node.

Code: Select all
--make crazy particles
 minetest.register_on_dignode(function(pos, oldnode, digger)
   --find node texture information
   local node = oldnode.name
   local tile = minetest.registered_nodes[node].tiles

   particle_explosion(tile,pos,25,90,140,1,2)
end)

--tile is the tile table,pos,amount minimum, math.random(amount_max,amount_max2)
function particle_explosion(tile,pos,amount_min,amount_max,amount_max2,time_min,time_max)
  for i = amount_min,math.random(amount_max,amount_max2) do
    --select random part of the texture
    local texsizer = math.random(1,3)
    local size = texsizer/3 --the texture size affects the particle size for consistancy
    local texsize = {x=texsizer,y=texsizer}
    local texpos = {x=math.random(-16,-1-texsizer),y=math.random(-16,-1-texsizer)}
    --filename1
    local texture = "[combine:"..texsize.x.."x"..texsize.y..":"..texpos.x..","..texpos.y.."="..tile[math.random(1,table.getn(tile))]
    minetest.add_particle({
      pos = {x=pos.x+(math.random()*math.random(-1,1)/2),y=pos.y+(math.random()*math.random(-1,1)/2),z=pos.z+(math.random()*math.random(-1,1)/2)},
      velocity = {
      x=math.random()*math.random(-3,3),
      y=math.random(2,4),
      z=math.random()*math.random(-3,3)},
      acceleration = {x=0, y=-10, z=0},
      expirationtime = math.random(time_min,time_max)/2,
      size = size,
      collisiondetection = true,
      collision_removal = false,
      object_collision = true,
      vertical = false,
      texture = texture,
    })
  end
end


I think it's rather neat!
Oil_boi
Member
 
Posts: 31
Joined: Mon Jan 28, 2019 1:12 pm
In-game: Oil_boi

Re: Mining Particles (Sections of a texture particles)

Postby texmex » Mon Apr 08, 2019 8:25 am

Oh, nice! I’ve been looking for exactly this.
texmex
Member
 
Posts: 1284
Joined: Mon Jul 11, 2016 9:08 pm
GitHub: tacotexmex
In-game: texmex



Return to Modding Discussion



Who is online

Users browsing this forum: Yandex Bot [Bot] and 0 guests