2 returnmirror
.cost_teleport
= 100
3 returnmirror
.cost_set
= 20
5 if tonumber(minetest
.setting_get("returnmirror_cost_teleport")) ~= nil then
6 returnmirror
.cost_teleport
= tonumber(minetest
.setting_get("returnmirror_cost_teleport"))
8 if tonumber(minetest
.setting_get("returnmirror_cost_set")) ~= nil then
9 returnmirror
.cost_set
= tonumber(minetest
.setting_get("returnmirror_cost_set"))
12 if minetest
.get_modpath("mana") ~= nil then
13 returnmirror
.mana
= true
15 returnmirror
.mana
= false
18 returnmirror
.mana_check
= function(player
, cost
)
20 if returnmirror
.mana
then
21 if mana
.subtract(player
:get_player_name(), cost
) then
32 minetest
.register_tool("returnmirror:returnmirror", {
33 description
= "Mirror of Returning",
35 inventory_image
= "returnmirror_returnmirror.png",
36 wield_image
= "returnmirror_returnmirror.png",
37 tool_capabilities
= {},
38 on_use
= function(itemstack
, user
, pointed_thing
)
39 local dest_string
= itemstack
:get_metadata()
40 local dest
= minetest
.string_to_pos(dest_string
)
42 if returnmirror
.mana_check(user
, returnmirror
.cost_teleport
) then
43 local src
= user
:getpos()
44 minetest
.sound_play( {name
="returnmirror_teleport", gain
=1}, {pos
=src
, max_hear_distance
=30})
45 minetest
.add_particlespawner({
48 minpos
= {x
=src
.x
-0.4, y
=src
.y
+0.25, z
=src
.z
-0.4},
49 maxpos
= {x
=src
.x
+0.4, y
=src
.y
+0.75, z
=src
.z
+0.4},
50 minvel
= {x
=-0.2, y
=-0.2, z
=-0.2},
51 maxvel
= {x
=0.2, y
=0.2, z
=0.2},
56 texture
= "returnmirror_particle_departure.png",
59 minetest
.sound_play( {name
="returnmirror_teleport", gain
=1}, {pos
=dest
, max_hear_distance
=30})
60 minetest
.add_particlespawner({
63 minpos
= {x
=dest
.x
-0.4, y
=dest
.y
+0.25, z
=dest
.z
-0.4},
64 maxpos
= {x
=dest
.x
+0.4, y
=dest
.y
+0.75, z
=dest
.z
+0.4},
65 minvel
= {x
=-0.4, y
=-0.3, z
=-0.4},
66 maxvel
= {x
=0.4, y
=0.3, z
=0.4},
71 texture
= "returnmirror_particle_arrival.png",
76 on_place
= function(itemstack
, placer
, pointed_thing
)
77 if returnmirror
.mana_check(placer
, returnmirror
.cost_set
) then
78 local pos
= placer
:getpos()
79 itemstack
:set_metadata(minetest
.pos_to_string(pos
))
80 minetest
.sound_play( {name
="returnmirror_set", gain
=1}, {pos
=pos
, max_hear_distance
=12})