Implements item groups soulbound and cursed (#105)

* Implements item groups soulbound and cursed:
Soulbound armors respawn with their owner.
Cursed armors cannot be unequipped by the player.
(disabled in creative mode)

* Prevents a cursed armor from getting unequipped by right clicking another piece of armor.
This commit is contained in:
Kyrah Abattoir
2023-05-31 14:59:20 +02:00
committed by GitHub
parent 053c30b8b1
commit 1d8509e75b
2 changed files with 16 additions and 4 deletions

View File

@ -681,6 +681,10 @@ armor.equip = function(self, player, itemstack)
for i=1, armor_inv:get_size("armor") do
local stack = armor_inv:get_stack("armor", i)
if self:get_element(stack:get_name()) == armor_element then
--prevents equiping an armor that would unequip a cursed armor.
if minetest.get_item_group(stack:get_name(), "cursed") ~= 0 then
return itemstack
end
index = i
self:unequip(player, armor_element)
break