2 returnmirror
.cost_teleport
= 100
3 returnmirror
.cost_set
= 20
5 if minetest
.get_modpath("mana") ~= nil then
6 returnmirror
.mana
= true
8 returnmirror
.mana
= false
11 returnmirror
.mana_check
= function(player
, cost
)
13 if returnmirror
.mana
then
14 if mana
.subtract(player
:get_player_name(), cost
) then
25 minetest
.register_tool("returnmirror:returnmirror", {
26 description
= "Mirror of Returning",
28 inventory_image
= "returnmirror_returnmirror.png",
29 wield_image
= "returnmirror_returnmirror.png",
30 tool_capabilities
= {},
31 on_use
= function(itemstack
, user
, pointed_thing
)
32 local dest_string
= itemstack
:get_metadata()
33 local dest
= minetest
.string_to_pos(dest_string
)
35 if returnmirror
.mana_check(user
, returnmirror
.cost_teleport
) then
36 local src
= user
:getpos()
37 minetest
.sound_play( {name
="returnmirror_teleport", gain
=1}, {pos
=src
, max_hear_distance
=30})
38 minetest
.add_particlespawner({
41 minpos
= {x
=src
.x
-0.4, y
=src
.y
+0.25, z
=src
.z
-0.4},
42 maxpos
= {x
=src
.x
+0.4, y
=src
.y
+0.75, z
=src
.z
+0.4},
43 minvel
= {x
=-0.2, y
=-0.2, z
=-0.2},
44 maxvel
= {x
=0.2, y
=0.2, z
=0.2},
49 texture
= "returnmirror_particle_departure.png",
52 minetest
.sound_play( {name
="returnmirror_teleport", gain
=1}, {pos
=dest
, max_hear_distance
=30})
53 minetest
.add_particlespawner({
56 minpos
= {x
=dest
.x
-0.4, y
=dest
.y
+0.25, z
=dest
.z
-0.4},
57 maxpos
= {x
=dest
.x
+0.4, y
=dest
.y
+0.75, z
=dest
.z
+0.4},
58 minvel
= {x
=-0.4, y
=-0.3, z
=-0.4},
59 maxvel
= {x
=0.4, y
=0.3, z
=0.4},
64 texture
= "returnmirror_particle_arrival.png",
69 on_place
= function(itemstack
, placer
, pointed_thing
)
70 if returnmirror
.mana_check(placer
, returnmirror
.cost_set
) then
71 local pos
= placer
:getpos()
72 itemstack
:set_metadata(minetest
.pos_to_string(pos
))
73 minetest
.sound_play( {name
="returnmirror_set", gain
=1}, {pos
=pos
, max_hear_distance
=12})