From eae5700e6ba236d2fb452b312327c25ae7e1b1f2 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Sun, 26 Apr 2015 18:02:15 +0200 Subject: [PATCH] Added work for "go to me" rune - Added mana dicreaser on on_punch calls (cube only :s) - Added is_owner handler - Moved a texture name to the good name - Added values in needed_mana for go_to_me rune --- mods/runes/api.lua | 7 +++++- mods/runes/handlers.lua | 21 +++++++++++++----- mods/runes/registration.lua | 17 +++++++------- ...prove_heal.png => runes_improved_heal.png} | Bin 4 files changed, 31 insertions(+), 14 deletions(-) rename mods/runes/textures/{runes_improve_heal.png => runes_improved_heal.png} (100%) diff --git a/mods/runes/api.lua b/mods/runes/api.lua index c689feb6..dca9e604 100644 --- a/mods/runes/api.lua +++ b/mods/runes/api.lua @@ -52,7 +52,12 @@ runes.functions.register_rune = function(parameters) end, on_punch = function(pos, node, puncher, pointed_thing) if runes.datas.handlers[runedef.name].on_punch then - runes.datas.handlers[runedef.name].on_punch(pos, node, puncher, pointed_thing) + if mana.get(puncher:get_player_name()) >= runedef.needed_mana then + runes.datas.handlers[runedef.name].on_punch(pos, node, puncher, pointed_thing) + mana.subtract(puncher:get_player_name(),runedef.needed_mana) + else + minetest.chat_send_player(puncher:get_player_name(),"Not enough mana (needed : " .. runedef.needed_mana ..")") + end end end, --[[after_dig_node = function(pos, oldnode, oldmetadata, digger) diff --git a/mods/runes/handlers.lua b/mods/runes/handlers.lua index 2ba6c4c7..9477f9db 100644 --- a/mods/runes/handlers.lua +++ b/mods/runes/handlers.lua @@ -39,13 +39,25 @@ is_owner_online = function(pos) if meta:get_string("owner") ~= nil then return minetest.get_player_by_name(meta:get_string("owner")) ~= nil else - return true + return false + end +end + +is_owner = function(pos, player) + local meta = minetest.get_meta(pos) + if meta:get_string("owner") ~= nil and player:get_player_name() then + return meta:get_string("owner") == player:get_player_name() + else + return false end end go_to_me = function(pos, node, digger) - if digger then + if digger and is_owner_online(pos) and not (minetest.get_meta(pos):get_string("owner") == digger:get_player_name()) then digger:setpos(minetest.get_player_by_name(minetest.get_meta(pos):get_string("owner")):getpos()) + mana.subtract(minetest.get_meta(pos):get_string("owner"), 5) + else + mana.add(digger:get_player_name(),50) end end @@ -75,9 +87,8 @@ end runes.functions.connect("project","use",projection) runes.functions.connect("damager","use",damage_around) runes.functions.connect("earthquake","use",earthquake) -runes.functions.connect("gotome","place",add_owner) -runes.functions.connect("gotome","dig",go_to_me) -runes.functions.connect("gotome","can_dig",is_owner_online) +runes.functions.connect("gotome","punch",go_to_me) +runes.functions.connect("gotome","can_dig",is_owner) runes.functions.connect("megamana","use",set_manamax) -- And globalsteps diff --git a/mods/runes/registration.lua b/mods/runes/registration.lua index a7f851c2..60c8c5d0 100644 --- a/mods/runes/registration.lua +++ b/mods/runes/registration.lua @@ -3,41 +3,42 @@ runes.datas.items = { ["project"] = { description = "Projection rune", - img = "default_dirt.png", + img = "runes_projection.png", type = "craftitem", needed_mana = 30 }, ["damager"] = { description = "Damaging rune", - img = "default_lava.png", + img = "runes_damaging.png", type = "craftitem", needed_mana = 190 }, ["earthquake"] = { description = "Earth Quake rune", - img = "default_apple.png", + img = "runes_earthquake.png", type = "craftitem", needed_mana = 80 }, ["simple_heal"] = { description = "Simple healing rune", - img = "default_water.png", + img = "runes_simple_heal.png", type = "cube" }, ["improved_heal"] = { description = "Improved healing rune", - img = "default_acid.png", + img = "runes_improved_heal.png", type = "cube" }, ["perfect_heal"] = { description = "Perfect healing rune", - img = "default_lava.png", + img = "runes_perfect_heal.png", type = "cube" }, ["gotome"] = { description = "Go to me rune", - img = "default_wood.png", - type = "cube" + img = "runes_go_to_me.png", + type = "cube", + needed_mana = 50 }, ["megamana"] = { description = "Mega Mana", diff --git a/mods/runes/textures/runes_improve_heal.png b/mods/runes/textures/runes_improved_heal.png similarity index 100% rename from mods/runes/textures/runes_improve_heal.png rename to mods/runes/textures/runes_improved_heal.png