From dc5d58ceb9e3e6dd44a68f3a5ba9db6a5a08344b Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 14 Feb 2015 00:02:35 +0100 Subject: [PATCH] Make dependency on Mana mod optional --- depends.txt | 2 +- init.lua | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/depends.txt b/depends.txt index d06ef53..309189f 100644 --- a/depends.txt +++ b/depends.txt @@ -1 +1 @@ -mana +mana? diff --git a/init.lua b/init.lua index a2487b4..b2fd1cc 100644 --- a/init.lua +++ b/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({