forked from mtcontrib/minetest_returnmirror
Make dependency on Mana mod optional
This commit is contained in:
parent
32f59bd4ff
commit
dc5d58ceb9
@ -1 +1 @@
|
||||
mana
|
||||
mana?
|
||||
|
18
init.lua
18
init.lua
@ -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({
|
||||
|
Loading…
Reference in New Issue
Block a user