From b89d49caf2c499533ab959320186972feb3c42cf Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Wed, 22 Jan 2020 14:32:52 +0200 Subject: [PATCH] Wand focus of light --- book.txt | 5 +++ focuses.lua | 43 +++++++++++++++++++++++++ register.lua | 14 ++++++++ textures/magicalities_focus_light.png | Bin 0 -> 709 bytes textures/magicalities_light_source.png | Bin 0 -> 493 bytes wands.lua | 8 +++-- 6 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 textures/magicalities_focus_light.png create mode 100644 textures/magicalities_light_source.png diff --git a/book.txt b/book.txt index 3fb8b6f..8d5edb3 100644 --- a/book.txt +++ b/book.txt @@ -42,6 +42,11 @@ The Transterra is a stone that can be used to create or remove nodes f The Elemental Ring can show you what elements a crystal contains and their quantities. #2magicalities:focus_blank The Blank Wand Focus is your gateway to the world of Wand Focuses. +Wand Focuses are used with the wand to peform magical activites. Right Click with your Wand to select a focus from your inventory. +#2magicalities:focus_swap +The Wand Focus of Swapping is a Wand Focus which can be used to replace nodes in the world with nodes in your inventory. Use Right Mouse Button to select the node to replace with and Left Mouse Button to replace nodes in the world. Each operation requires 1 Earth. +#2magicalities:focus_light +The Wand Focus of Light is a Wand Focus which can be used to place light source nodes in place of stone. Each node of light takes 1 Light element. #2magicalities:axe_tellium Tellium Axe is a Diamond-tier tool that can be empowered by right-clicking. In empowered mode, the axe is 2x as fast but breaks about 4x faster. #2magicalities:pick_tellium diff --git a/focuses.lua b/focuses.lua index ea19414..bf7bfd3 100644 --- a/focuses.lua +++ b/focuses.lua @@ -72,6 +72,7 @@ minetest.register_craftitem("magicalities:focus_swap", { local pos = pointed_thing.under if minetest.is_protected(pos, pname) then + minetest.record_protection_violation(pos, pname) return itemstack end @@ -129,6 +130,48 @@ minetest.register_craftitem("magicalities:focus_swap", { end }) +-- Light Source +minetest.register_node("magicalities:light_source", { + description = "Magical Light Source", + tiles = {"magicalities_light_source.png"}, + groups = {cracky = 3, not_in_creative_inventory = 1}, + light_source = 13, + drop = "" +}) + +minetest.register_craftitem("magicalities:focus_light", { + description = "Wand Focus of Light", + groups = {wand_focus = 1}, + inventory_image = "magicalities_focus_light.png", + stack_max = 1, + _wand_requirements = { + ["light"] = 1 + }, + _wand_use = function(itemstack, user, pointed_thing) + if pointed_thing.type ~= "node" then + return + end + + local pos = pointed_thing.under + local pname = user:get_player_name() + + if minetest.is_protected(pos, pname) then + minetest.record_protection_violation(pos, pname) + return + end + + local node = minetest.get_node(pos).name + + if node == "default:stone" or node == "default:desert_stone" then + minetest.swap_node(pos, {name = "magicalities:light_source"}) + itemstack = magicalities.wands.wand_take_contents(itemstack, {light = 1}) + magicalities.wands.update_wand_desc(itemstack) + end + + return itemstack + end, +}) + --------------- -- Tunneling -- --------------- diff --git a/register.lua b/register.lua index 82e4551..d2c58c9 100644 --- a/register.lua +++ b/register.lua @@ -226,6 +226,20 @@ local recipes = { requirements = { ["air"] = 10, }, + learnable = { + depends = {"magicalities:focus_atk_air"} + } + }, + { + input = { + {"magicalities:crystal_light", "magicalities:crystal_block_light", "magicalities:crystal_light"}, + {"default:stone", "magicalities:focus_blank", "default:stone"}, + {"magicalities:crystal_light", "magicalities:crystal_block_light", "magicalities:crystal_light"} + }, + output = "magicalities:focus_light", + requirements = { + ["light"] = 10, + }, learnable = { depends = {"magicalities:focus_blank"} } diff --git a/textures/magicalities_focus_light.png b/textures/magicalities_focus_light.png new file mode 100644 index 0000000000000000000000000000000000000000..da3a2586d0d53a65c362122d1fb44de00839bf89 GIT binary patch literal 709 zcmV;$0y_PPP)Px#24YJ`L;y?xF#r`TG-Z1L000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2jl@3 z3p*0ZO`}!-0013nR9JLFZ*6U5Zgc_CX>@2HM@dakWG-a~0006U zNklA7dc~g9ZZPw8K1{!#M-||=zWh{tGD&B z0MDOoC1PMU+w+Q{oHg9;?PnpaVvuy>=4x>yV0-&zt|}|D+2@qg1a&>;@wlPh2ei{3 zlSwZz8o7Mss`&%(`qhgxH(!L&NZFh|Wb3>*SHPIlEZHI^!L;pV+Cse7@xsMRB>)`w zO1UMihNyMa#aOa2l_Hu0P=J`BbQU6;tR08mYy0bt0pQ_-`*}Pnr6^QojE}|;6V*gi zGf~N)l8B0+wc2BrKur1F+c)7i1(KMR(uT6N1(*#31pp<0B7m|;5)oxtIcHsIjLC8U zNHJr-?NU{uud0fGIRFLy6qrOL2Eeljk3^W2QdC%%4=ey0AK!n%?w5Vl`wS5a5e)zW zAOis+T?(N`N{NURjI)PR*xGy&n*}F}XKI{0b%L#R0EP_s?>P&ln4Rw}hhaqCtGsyj zyg8JD?*bQ9)%Shnrfou54x+ShN>qfQr!0!H zJEaYE-83t9)DI#%JG)q3zNU|?^1Zuvk}IvZR@OKPr}M>p&8Wb%!MA=1jqbw1WJ rt*@^SbzP^XX{=I;*4EY-|6_gtj*bBijL}yx00000NkvXXu0mjf*L*2x literal 0 HcmV?d00001 diff --git a/textures/magicalities_light_source.png b/textures/magicalities_light_source.png new file mode 100644 index 0000000000000000000000000000000000000000..ba2665d289019a5e9811f24128f90bc342ff1f9d GIT binary patch literal 493 zcmVPx#24YJ`L;y?xF#r`TG-Z1L000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2jl@3 z3_CX>@2HM@dakWG-a~0003* zNkl?i3`5aRN=A+__dijtW4lXY7M?}2n9jN&puqq1dj4LCaiQI|Kmc+9 zyk^d?LXzb;_#V81hNxtRzb0wmQ1pOlVp^w_bOG@$fl^zabPBbkPOgBkF=fdb$xbmvJHS5 z%ftYXDB*ihEL)PaEuFE;vuY89B3nX01uO`*kd)PDq0f7^tG)`ofH&5XKqAgT_R6mO z?WFyWlWplRH=SkQI_Wd-+s>Kyt&^Vfy6v3It&{eDI`8MJKRW5E`_9s(J16bWnm=|< j?wvF=cb#_+cTWBQu)1r^9rQ!;00000NkvXXu0mjfq_50! literal 0 HcmV?d00001 diff --git a/wands.lua b/wands.lua index 9d36f31..26cc801 100644 --- a/wands.lua +++ b/wands.lua @@ -196,7 +196,7 @@ function magicalities.wands.wand_take_contents(stack, to_take) for name, count in pairs(to_take) do if not data_table[name] or data_table[name] - count < 0 then - return nil + return stack end data_table[name] = data_table[name] - count @@ -300,10 +300,11 @@ end local function use_wand(itemstack, user, pointed_thing) local imeta = itemstack:get_meta() + local pname = user:get_player_name() -- Initialize wand metadata if imeta:get_string("contents") == "" then - initialize_wand(itemstack, user:get_player_name()) + initialize_wand(itemstack, pname) magicalities.wands.update_wand_desc(itemstack) end @@ -325,7 +326,8 @@ local function use_wand(itemstack, user, pointed_thing) local pos = pointed_thing.under local node = minetest.get_node_or_nil(pos) - if not node or node.name == "air" or minetest.is_protected(pos, user:get_player_name()) then + if not node or node.name == "air" or minetest.is_protected(pos, pname) then + minetest.record_protection_violation(pos, pname) magicalities.wands.update_wand_desc(itemstack) return itemstack end