Advertisement
Guest User

Untitled

a guest
Apr 7th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.97 KB | None | 0 0
  1. on_use = function(itemstack, user, pointed_thing)
  2.           if not pointed_thing.under then
  3.             return
  4.           end
  5.  
  6.           local node = minetest.get_node(pointed_thing.under).name
  7.           local tile = minetest.registered_nodes[node].tiles
  8.  
  9.  
  10.  
  11.           --do a translation from c++ mining particle source to lua
  12.           --https://github.com/minetest/minetest/blob/master/src/client/particles.cpp#L612
  13.           --[[
  14.           local size = (math.random() % 8) / 64.0
  15.             local visual_size = 10 * size
  16.             --if (tile.scale)
  17.             --  size /= tile.scale;
  18.             local texsize = {x = size * 2.0,y = size * 2.0}
  19.             local texpos = {}
  20.             texpos.x = (math.random() % 64) / 64 - texsize.x
  21.             texpos.y = (math.random() % 64) / 64 - texsize.y
  22.  
  23.           texsize = {x=texsize.x*1000,y=texsize.y*1000}
  24.           ]]--
  25.  
  26.           local size = math.random(1,10)/10
  27.           local texsizer = math.random(1,3)
  28.           local texsize = {x=texsizer,y=texsizer}
  29.           local texpos = {x=math.random(1,16-texsize.x)/64,y=math.random(1,16-texsize.y)/64}
  30.  
  31.           print(dump(texsize))
  32.           print(dump(texpos))
  33.           --filename1
  34.           local texture = "[combine:"..texsize.x.."x"..texsize.y..":"..texpos.x..","..texpos.y.."="..tile[math.random(1,table.getn(tile))]
  35.  
  36.           local pos1 = pointed_thing.above
  37.           minetest.add_particlespawner({
  38.               amount = math.random(40,90),
  39.               -- Number of particles spawned over the time period `time`.
  40.  
  41.               time = 0.1,
  42.               -- Lifespan of spawner in seconds.
  43.               -- If time is 0 spawner has infinite lifespan and spawns the `amount` on
  44.               -- a per-second basis.
  45.  
  46.               minpos = pos1,
  47.               maxpos = pos1,
  48.               minvel = {x=-5, y=4, z=-5},
  49.               maxvel = {x=5, y=7, z=5},
  50.               minacc = {x=0, y=-10, z=0},
  51.               maxacc = {x=0, y=-10, z=0},
  52.               minexptime = 2,
  53.               maxexptime = 4,
  54.               minsize = 1,
  55.               maxsize = 2,
  56.               -- The particles' properties are random values between the min and max
  57.               -- values.
  58.               -- pos, velocity, acceleration, expirationtime, size
  59.  
  60.               collisiondetection = true,
  61.               -- If true collide with `walkable` nodes and, depending on the
  62.               -- `object_collision` field, objects too.
  63.  
  64.               collision_removal = false,
  65.               -- If true particles are removed when they collide.
  66.               -- Requires collisiondetection = true to have any effect.
  67.  
  68.               object_collision = true,
  69.               -- If true particles collide with objects that are defined as
  70.               -- `physical = true,` and `collide_with_objects = true,`.
  71.  
  72.               texture = texture,
  73.  
  74.  
  75.               --animation = {Tile Animation definition},
  76.               -- Optional, specifies how to animate the particles' texture
  77.           })
  78.         end,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement