Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- on_use = function(itemstack, user, pointed_thing)
- if not pointed_thing.under then
- return
- end
- local node = minetest.get_node(pointed_thing.under).name
- local tile = minetest.registered_nodes[node].tiles
- --do a translation from c++ mining particle source to lua
- --https://github.com/minetest/minetest/blob/master/src/client/particles.cpp#L612
- --[[
- local size = (math.random() % 8) / 64.0
- local visual_size = 10 * size
- --if (tile.scale)
- -- size /= tile.scale;
- local texsize = {x = size * 2.0,y = size * 2.0}
- local texpos = {}
- texpos.x = (math.random() % 64) / 64 - texsize.x
- texpos.y = (math.random() % 64) / 64 - texsize.y
- texsize = {x=texsize.x*1000,y=texsize.y*1000}
- ]]--
- local size = math.random(1,10)/10
- local texsizer = math.random(1,3)
- local texsize = {x=texsizer,y=texsizer}
- local texpos = {x=math.random(1,16-texsize.x)/64,y=math.random(1,16-texsize.y)/64}
- print(dump(texsize))
- print(dump(texpos))
- --filename1
- local texture = "[combine:"..texsize.x.."x"..texsize.y..":"..texpos.x..","..texpos.y.."="..tile[math.random(1,table.getn(tile))]
- local pos1 = pointed_thing.above
- minetest.add_particlespawner({
- amount = math.random(40,90),
- -- Number of particles spawned over the time period `time`.
- time = 0.1,
- -- Lifespan of spawner in seconds.
- -- If time is 0 spawner has infinite lifespan and spawns the `amount` on
- -- a per-second basis.
- minpos = pos1,
- maxpos = pos1,
- minvel = {x=-5, y=4, z=-5},
- maxvel = {x=5, y=7, z=5},
- minacc = {x=0, y=-10, z=0},
- maxacc = {x=0, y=-10, z=0},
- minexptime = 2,
- maxexptime = 4,
- minsize = 1,
- maxsize = 2,
- -- The particles' properties are random values between the min and max
- -- values.
- -- pos, velocity, acceleration, expirationtime, size
- collisiondetection = true,
- -- If true collide with `walkable` nodes and, depending on the
- -- `object_collision` field, objects too.
- collision_removal = false,
- -- If true particles are removed when they collide.
- -- Requires collisiondetection = true to have any effect.
- object_collision = true,
- -- If true particles collide with objects that are defined as
- -- `physical = true,` and `collide_with_objects = true,`.
- texture = texture,
- --animation = {Tile Animation definition},
- -- Optional, specifies how to animate the particles' texture
- })
- end,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement