Make dependency on Mana mod optional

This commit is contained in:
Wuzzy 2015-02-14 00:02:35 +01:00
parent 32f59bd4ff
commit dc5d58ceb9
2 changed files with 18 additions and 2 deletions

View File

@ -1 +1 @@
mana
mana?

View File

@ -1,6 +1,12 @@
returnmirror = {}
returnmirror.cost = 100
if minetest.get_modpath("mana") ~= nil then
returnmirror.mana = true
else
returnmirror.mana = false
end
minetest.register_tool("returnmirror:returnmirror", {
description = "Mirror of Returning",
stack_max = 1,
@ -11,7 +17,17 @@ minetest.register_tool("returnmirror:returnmirror", {
local dest_string = itemstack:get_metadata()
local dest = minetest.string_to_pos(dest_string)
if dest ~= nil then
if mana.subtract(user:get_player_name(), returnmirror.cost) then
local allowed
if returnmirror.mana then
if mana.subtract(user:get_player_name(), returnmirror.cost) then
allowed = true
else
allowed = false
end
else
allowed = true
end
if allowed then
local src = user:getpos()
minetest.sound_play( {name="returnmirror_teleport", gain=1}, {pos=src, max_hear_distance=30})
minetest.add_particlespawner({