2 returnmirror
.cost
= 100
4 minetest
.register_tool("returnmirror:returnmirror", {
5 description
= "Mirror of Returning",
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
)
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({
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},
28 texture
= "returnmirror_particle_departure.png",
31 minetest
.sound_play( {name
="returnmirror_teleport", gain
=1}, {pos
=dest
, max_hear_distance
=30})
32 minetest
.add_particlespawner({
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},
43 texture
= "returnmirror_particle_arrival.png",
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})