More research regarding crystals

This commit is contained in:
Evert Prants 2019-11-08 15:25:38 +02:00
parent 2059faeaa0
commit a244fb548a
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
6 changed files with 51 additions and 5 deletions

View File

@ -57,7 +57,7 @@ minetest.register_craftitem("magicalities:tellium", {
})
minetest.register_craftitem("magicalities:transterra", {
description = "Transterra",
description = "Transterra\nThis substance can change the world!",
inventory_image = "magicalities_red_stone.png",
groups = {shard = 1, transterra = 1}
})

View File

@ -71,6 +71,20 @@ function magicalities.crystals.generate_crystal_buffer(pos)
return final
end
-- If content goes to zero, remove element from crystal
local function update_contents(pos, contents)
local meta = minetest.get_meta(pos)
local keep = {}
for name,data in pairs(contents) do
if data[1] > 0 then
keep[name] = data
end
end
meta:set_string("contents", minetest.serialize(keep))
end
local function crystal_rightclick(pos, node, clicker, itemstack, pointed_thing)
local meta = minetest.get_meta(pos)
@ -86,10 +100,27 @@ local function crystal_rightclick(pos, node, clicker, itemstack, pointed_thing)
return itemstack
end
-- Check if player can preserve this crystal
local preserve = magicalities.player_has_ability(clicker:get_player_name(), "magicalities:crystal_preserve")
local mincheck = 0
if preserve then mincheck = 1 end
-- Check if we can take more than one
local draining = magicalities.player_has_ability(clicker:get_player_name(), "magicalities:crystal_draining")
local maxtake = 1
if draining then maxtake = 5 end
local one_of_each = {}
for name, count in pairs(contents) do
if count[1] > 0 then
one_of_each[name] = 1
if count[1] > mincheck then
local take = maxtake
if count[1] <= maxtake then
take = count[1] - mincheck
end
if take > 0 then
one_of_each[name] = take
end
end
end
@ -126,7 +157,7 @@ local function crystal_rightclick(pos, node, clicker, itemstack, pointed_thing)
itemstack = magicalities.wands.wand_insert_contents(itemstack, can_put)
magicalities.wands.update_wand_desc(itemstack)
meta:set_string("contents", minetest.serialize(contents))
update_contents(pos, contents)
return itemstack
end

View File

@ -360,9 +360,24 @@ end
-- Abilities
magicalities.register_ability_learnable({
name = "magicalities:crystal_preserve",
description = "Crystal Preservation\nAvoid collecting every last drop of elements",
icon = "magicalities_crystal_preservation.png"
})
magicalities.register_ability_learnable({
name = "magicalities:crystal_draining",
description = "Efficient Crystal Draining\nIncrease element drain rate",
depends = {"magicalities:crystal_preserve"},
icon = "magicalities_crystal_draining.png"
})
magicalities.register_ability_learnable({
name = "magicalities:pickup_jarred",
description = "Crystal Jarring"
description = "Crystal Jarring\nPick up intact crystals using jarring",
depends = {"magicalities:crystal_preserve"},
icon = "magicalities_jarred.png"
})
magicalities.register_recipe_learnable({

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB