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 0000000..da3a258
Binary files /dev/null and b/textures/magicalities_focus_light.png differ
diff --git a/textures/magicalities_light_source.png b/textures/magicalities_light_source.png
new file mode 100644
index 0000000..ba2665d
Binary files /dev/null and b/textures/magicalities_light_source.png differ
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