2 returnmirror
.cost_teleport
= 200
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 returnmirror
.set_position_inactive
= function(itemstack
, user
, pointed_thing
)
33 if returnmirror
.mana_check(user
, returnmirror
.cost_set
) then
34 local pos
= user
:getpos()
35 local newitem
= ItemStack("returnmirror:mirror_active")
36 newitem
:set_metadata(minetest
.pos_to_string(pos
))
37 minetest
.sound_play( {name
="returnmirror_set", gain
=1}, {pos
=pos
, max_hear_distance
=12})
42 returnmirror
.set_position_active
= function(itemstack
, user
, pointed_thing
)
43 if returnmirror
.mana_check(user
, returnmirror
.cost_set
) then
44 local pos
= user
:getpos()
45 itemstack
:set_metadata(minetest
.pos_to_string(pos
))
46 minetest
.sound_play( {name
="returnmirror_set", gain
=1}, {pos
=pos
, max_hear_distance
=12})
51 minetest
.register_tool("returnmirror:mirror_inactive", {
52 description
= "Mirror of Returning",
53 inventory_image
= "returnmirror_mirror_inactive.png",
54 wield_image
= "returnmirror_mirror_inactive.png",
55 tool_capabilities
= {},
57 on_use
= function() end,
58 on_place
= returnmirror
.set_position_inactive
,
59 on_secondary_use
= returnmirror
.set_position_inactive
,
62 minetest
.register_tool("returnmirror:mirror_active", {
63 description
= "Mirror of Returning",
65 inventory_image
= "returnmirror_mirror_active.png",
66 wield_image
= "returnmirror_mirror_active.png",
67 tool_capabilities
= {},
69 on_use
= function(itemstack
, user
, pointed_thing
)
70 local dest_string
= itemstack
:get_metadata()
71 local dest
= minetest
.string_to_pos(dest_string
)
73 if returnmirror
.mana_check(user
, returnmirror
.cost_teleport
) then
74 local src
= user
:getpos()
75 minetest
.sound_play( {name
="returnmirror_teleport", gain
=1}, {pos
=src
, max_hear_distance
=30})
76 minetest
.add_particlespawner({
79 minpos
= {x
=src
.x
-0.4, y
=src
.y
+0.25, z
=src
.z
-0.4},
80 maxpos
= {x
=src
.x
+0.4, y
=src
.y
+0.75, z
=src
.z
+0.4},
81 minvel
= {x
=-0.2, y
=-0.2, z
=-0.2},
82 maxvel
= {x
=0.2, y
=0.2, z
=0.2},
87 texture
= "returnmirror_particle_departure.png",
90 minetest
.sound_play( {name
="returnmirror_teleport", gain
=1}, {pos
=dest
, max_hear_distance
=30})
91 minetest
.add_particlespawner({
94 minpos
= {x
=dest
.x
-0.4, y
=dest
.y
+0.25, z
=dest
.z
-0.4},
95 maxpos
= {x
=dest
.x
+0.4, y
=dest
.y
+0.75, z
=dest
.z
+0.4},
96 minvel
= {x
=-0.4, y
=-0.3, z
=-0.4},
97 maxvel
= {x
=0.4, y
=0.3, z
=0.4},
102 texture
= "returnmirror_particle_arrival.png",
107 on_place
= returnmirror
.set_position_active
,
108 on_secondary_use
= returnmirror
.set_position_active
,
109 groups
= { not_in_creative_inventory
= 1 },
112 minetest
.register_alias("returnmirror:mirror_inactive", "returnmirror:returnmirror")