Make mana cost configurable

master
Wuzzy 2015-02-16 04:00:25 +01:00
parent 1580db57ba
commit 5216fb3b83
2 changed files with 7 additions and 1 deletions

View File

@ -27,3 +27,4 @@ configuration is recommended. But you can change it anyways, if you wish. Config
* `teletool_avoid_collisions`: Boolean. If `true`, it is not possible to teleport somewhere where you would collide with a node. Default: `true`.
* `teletool_adjust_head`: Boolean. If `true`, you will be teleported one node lower if you clicked on the lower side of a node. Otherwise, your “head” will be initially “stuck” in the node. Default: `true`.
* `teletool_cost_mana`: Number. Cost of mana for the magic point teleporter. Default: `20`.

View File

@ -11,6 +11,7 @@ teletool = {}
teletool.settings = {}
teletool.settings.avoid_collisions = true
teletool.settings.adjust_head = true
teletool.settings.cost_mana = 20
local avoid_collisions = minetest.setting_getbool("teletool_avoid_collisions")
if avoid_collisions ~= nil then
teletool.settings.avoid_collision = avoid_collisions
@ -19,6 +20,10 @@ local adjust_head = minetest.setting_getbool("teletool_adjust_head")
if adjust_head ~= nil then
teletool.settings.adjust_head = adjust_head
end
local cost_mana = tonumber(minetest.setting_get("teletool_cost_mana"))
if cost_mana ~= nil then
teletool.settings.cost_mana = cost_mana
end
function teletool.teleport(player, pointed_thing)
@ -150,7 +155,7 @@ if(minetest.get_modpath("mana") ~= nil) then
on_use = function(itemstack, user, pointed_thing)
local failure = false
if(pointed_thing.type == "node") then
if(mana.subtract(user:get_player_name(), 20)) then
if(mana.subtract(user:get_player_name(), teletool.settings.cost_mana)) then
failure = not teletool.teleport(user, pointed_thing)
else
failure = true