Add simple particles
[minetest_returnmirror.git] / init.lua
bloba2487b4fd243cf112c7c3a8ed1e7a6f6df58a66e
1 returnmirror = {}
2 returnmirror.cost = 100
4 minetest.register_tool("returnmirror:returnmirror", {
5 description = "Mirror of Returning",
6 stack_max = 1,
7 inventory_image = "returnmirror_returnmirror.png",
8 wield_image = "returnmirror_returnmirror.png",
9 tool_capabilities = {},
10 on_use = function(itemstack, user, pointed_thing)
11 local dest_string = itemstack:get_metadata()
12 local dest = minetest.string_to_pos(dest_string)
13 if dest ~= nil then
14 if mana.subtract(user:get_player_name(), returnmirror.cost) then
15 local src = user:getpos()
16 minetest.sound_play( {name="returnmirror_teleport", gain=1}, {pos=src, max_hear_distance=30})
17 minetest.add_particlespawner({
18 amount = 50,
19 time = 0.1,
20 minpos = {x=src.x-0.4, y=src.y+0.25, z=src.z-0.4},
21 maxpos = {x=src.x+0.4, y=src.y+0.75, z=src.z+0.4},
22 minvel = {x=-0.2, y=-0.2, z=-0.2},
23 maxvel = {x=0.2, y=0.2, z=0.2},
24 minexptime=3,
25 maxexptime=4.5,
26 minsize=1,
27 maxsize=1.25,
28 texture = "returnmirror_particle_departure.png",
30 user:setpos(dest)
31 minetest.sound_play( {name="returnmirror_teleport", gain=1}, {pos=dest, max_hear_distance=30})
32 minetest.add_particlespawner({
33 amount = 100,
34 time = 0.1,
35 minpos = {x=dest.x-0.4, y=dest.y+0.25, z=dest.z-0.4},
36 maxpos = {x=dest.x+0.4, y=dest.y+0.75, z=dest.z+0.4},
37 minvel = {x=-0.4, y=-0.3, z=-0.4},
38 maxvel = {x=0.4, y=0.3, z=0.4},
39 minexptime=6,
40 maxexptime=12,
41 minsize=1,
42 maxsize=1.25,
43 texture = "returnmirror_particle_arrival.png",
45 end
46 end
47 end,
48 on_place = function(itemstack, placer, pointed_thing)
49 local pos = placer:getpos()
50 itemstack:set_metadata(minetest.pos_to_string(pos))
51 minetest.sound_play( {name="returnmirror_set", gain=1}, {pos=pos, max_hear_distance=12})
52 return itemstack
53 end