forked from VoxeLibre/VoxeLibre
Wear armor on rightclick item
This commit is contained in:
parent
bd23bb956a
commit
a539b25b08
|
@ -1,5 +1,36 @@
|
||||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/armor.lua")
|
dofile(minetest.get_modpath(minetest.get_current_modname()).."/armor.lua")
|
||||||
|
|
||||||
|
local wear_armor = function(itemstack, user, pointed_thing)
|
||||||
|
local groups = minetest.registered_items[itemstack:get_name()].groups
|
||||||
|
local slot
|
||||||
|
if groups then
|
||||||
|
if groups.armor_head then
|
||||||
|
slot = 2
|
||||||
|
elseif groups.armor_torso then
|
||||||
|
slot = 3
|
||||||
|
elseif groups.armor_legs then
|
||||||
|
slot = 4
|
||||||
|
elseif groups.armor_feet then
|
||||||
|
slot = 5
|
||||||
|
end
|
||||||
|
if slot then
|
||||||
|
local ainv = minetest.get_inventory({type="detached", name=user:get_player_name().."_armor"})
|
||||||
|
local inv = user:get_inventory()
|
||||||
|
local old = inv:get_stack("armor", slot)
|
||||||
|
ainv:set_stack("armor", slot, itemstack)
|
||||||
|
inv:set_stack("armor", slot, itemstack)
|
||||||
|
armor:set_player_armor(user)
|
||||||
|
armor:update_inventory(user)
|
||||||
|
if old:is_empty() then
|
||||||
|
itemstack:take_item()
|
||||||
|
else
|
||||||
|
itemstack = old
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
-- Regisiter Head Armor
|
-- Regisiter Head Armor
|
||||||
|
|
||||||
minetest.register_tool("3d_armor:helmet_leather", {
|
minetest.register_tool("3d_armor:helmet_leather", {
|
||||||
|
@ -7,6 +38,8 @@ minetest.register_tool("3d_armor:helmet_leather", {
|
||||||
inventory_image = "3d_armor_inv_helmet_leather.png",
|
inventory_image = "3d_armor_inv_helmet_leather.png",
|
||||||
groups = {armor_head=5, armor_heal=0, armor_use=100},
|
groups = {armor_head=5, armor_heal=0, armor_use=100},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("3d_armor:helmet_iron", {
|
minetest.register_tool("3d_armor:helmet_iron", {
|
||||||
|
@ -14,6 +47,8 @@ minetest.register_tool("3d_armor:helmet_iron", {
|
||||||
inventory_image = "3d_armor_inv_helmet_iron.png",
|
inventory_image = "3d_armor_inv_helmet_iron.png",
|
||||||
groups = {armor_head=10, armor_heal=5, armor_use=250},
|
groups = {armor_head=10, armor_heal=5, armor_use=250},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("3d_armor:helmet_gold", {
|
minetest.register_tool("3d_armor:helmet_gold", {
|
||||||
|
@ -21,6 +56,8 @@ minetest.register_tool("3d_armor:helmet_gold", {
|
||||||
inventory_image = "3d_armor_inv_helmet_gold.png",
|
inventory_image = "3d_armor_inv_helmet_gold.png",
|
||||||
groups = {armor_head=15, armor_heal=10, armor_use=500},
|
groups = {armor_head=15, armor_heal=10, armor_use=500},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("3d_armor:helmet_diamond",{
|
minetest.register_tool("3d_armor:helmet_diamond",{
|
||||||
|
@ -28,6 +65,8 @@ minetest.register_tool("3d_armor:helmet_diamond",{
|
||||||
inventory_image = "3d_armor_inv_helmet_diamond.png",
|
inventory_image = "3d_armor_inv_helmet_diamond.png",
|
||||||
groups = {armor_head=20, armor_heal=15, armor_use=750},
|
groups = {armor_head=20, armor_heal=15, armor_use=750},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("3d_armor:helmet_chain", {
|
minetest.register_tool("3d_armor:helmet_chain", {
|
||||||
|
@ -35,6 +74,8 @@ minetest.register_tool("3d_armor:helmet_chain", {
|
||||||
inventory_image = "3d_armor_inv_helmet_chain.png",
|
inventory_image = "3d_armor_inv_helmet_chain.png",
|
||||||
groups = {armor_head=15, armor_heal=10, armor_use=500},
|
groups = {armor_head=15, armor_heal=10, armor_use=500},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Regisiter Torso Armor
|
-- Regisiter Torso Armor
|
||||||
|
@ -44,6 +85,8 @@ minetest.register_tool("3d_armor:chestplate_leather", {
|
||||||
inventory_image = "3d_armor_inv_chestplate_leather.png",
|
inventory_image = "3d_armor_inv_chestplate_leather.png",
|
||||||
groups = {armor_torso=15, armor_heal=0, armor_use=100},
|
groups = {armor_torso=15, armor_heal=0, armor_use=100},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("3d_armor:chestplate_iron", {
|
minetest.register_tool("3d_armor:chestplate_iron", {
|
||||||
|
@ -51,6 +94,8 @@ minetest.register_tool("3d_armor:chestplate_iron", {
|
||||||
inventory_image = "3d_armor_inv_chestplate_iron.png",
|
inventory_image = "3d_armor_inv_chestplate_iron.png",
|
||||||
groups = {armor_torso=20, armor_heal=5, armor_use=250},
|
groups = {armor_torso=20, armor_heal=5, armor_use=250},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("3d_armor:chestplate_gold", {
|
minetest.register_tool("3d_armor:chestplate_gold", {
|
||||||
|
@ -58,6 +103,8 @@ minetest.register_tool("3d_armor:chestplate_gold", {
|
||||||
inventory_image = "3d_armor_inv_chestplate_gold.png",
|
inventory_image = "3d_armor_inv_chestplate_gold.png",
|
||||||
groups = {armor_torso=25, armor_heal=10, armor_use=500},
|
groups = {armor_torso=25, armor_heal=10, armor_use=500},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("3d_armor:chestplate_diamond",{
|
minetest.register_tool("3d_armor:chestplate_diamond",{
|
||||||
|
@ -65,6 +112,8 @@ minetest.register_tool("3d_armor:chestplate_diamond",{
|
||||||
inventory_image = "3d_armor_inv_chestplate_diamond.png",
|
inventory_image = "3d_armor_inv_chestplate_diamond.png",
|
||||||
groups = {armor_torso=30, armor_heal=15, armor_use=750},
|
groups = {armor_torso=30, armor_heal=15, armor_use=750},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("3d_armor:chestplate_chain", {
|
minetest.register_tool("3d_armor:chestplate_chain", {
|
||||||
|
@ -72,6 +121,8 @@ minetest.register_tool("3d_armor:chestplate_chain", {
|
||||||
inventory_image = "3d_armor_inv_chestplate_chain.png",
|
inventory_image = "3d_armor_inv_chestplate_chain.png",
|
||||||
groups = {armor_torso=25, armor_heal=10, armor_use=500},
|
groups = {armor_torso=25, armor_heal=10, armor_use=500},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Regisiter Leg Armor
|
-- Regisiter Leg Armor
|
||||||
|
@ -81,6 +132,8 @@ minetest.register_tool("3d_armor:leggings_leather", {
|
||||||
inventory_image = "3d_armor_inv_leggings_leather.png",
|
inventory_image = "3d_armor_inv_leggings_leather.png",
|
||||||
groups = {armor_legs=10, armor_heal=0, armor_use=100},
|
groups = {armor_legs=10, armor_heal=0, armor_use=100},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("3d_armor:leggings_iron", {
|
minetest.register_tool("3d_armor:leggings_iron", {
|
||||||
|
@ -88,6 +141,8 @@ minetest.register_tool("3d_armor:leggings_iron", {
|
||||||
inventory_image = "3d_armor_inv_leggings_iron.png",
|
inventory_image = "3d_armor_inv_leggings_iron.png",
|
||||||
groups = {armor_legs=15, armor_heal=5, armor_use=250},
|
groups = {armor_legs=15, armor_heal=5, armor_use=250},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("3d_armor:leggings_gold", {
|
minetest.register_tool("3d_armor:leggings_gold", {
|
||||||
|
@ -95,6 +150,8 @@ minetest.register_tool("3d_armor:leggings_gold", {
|
||||||
inventory_image = "3d_armor_inv_leggings_gold.png",
|
inventory_image = "3d_armor_inv_leggings_gold.png",
|
||||||
groups = {armor_legs=20, armor_heal=10, armor_use=500},
|
groups = {armor_legs=20, armor_heal=10, armor_use=500},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("3d_armor:leggings_diamond",{
|
minetest.register_tool("3d_armor:leggings_diamond",{
|
||||||
|
@ -102,6 +159,8 @@ minetest.register_tool("3d_armor:leggings_diamond",{
|
||||||
inventory_image = "3d_armor_inv_leggings_diamond.png",
|
inventory_image = "3d_armor_inv_leggings_diamond.png",
|
||||||
groups = {armor_legs=25, armor_heal=15, armor_use=750},
|
groups = {armor_legs=25, armor_heal=15, armor_use=750},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("3d_armor:leggings_chain", {
|
minetest.register_tool("3d_armor:leggings_chain", {
|
||||||
|
@ -109,6 +168,8 @@ minetest.register_tool("3d_armor:leggings_chain", {
|
||||||
inventory_image = "3d_armor_inv_leggings_chain.png",
|
inventory_image = "3d_armor_inv_leggings_chain.png",
|
||||||
groups = {armor_legs=20, armor_heal=10, armor_use=500},
|
groups = {armor_legs=20, armor_heal=10, armor_use=500},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
-- Regisiter Boots
|
-- Regisiter Boots
|
||||||
|
|
||||||
|
@ -117,6 +178,8 @@ minetest.register_tool("3d_armor:boots_leather", {
|
||||||
inventory_image = "3d_armor_inv_boots_leather.png",
|
inventory_image = "3d_armor_inv_boots_leather.png",
|
||||||
groups = {armor_feet=5, armor_heal=0, armor_use=100},
|
groups = {armor_feet=5, armor_heal=0, armor_use=100},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("3d_armor:boots_iron", {
|
minetest.register_tool("3d_armor:boots_iron", {
|
||||||
|
@ -124,6 +187,8 @@ minetest.register_tool("3d_armor:boots_iron", {
|
||||||
inventory_image = "3d_armor_inv_boots_iron.png",
|
inventory_image = "3d_armor_inv_boots_iron.png",
|
||||||
groups = {armor_feet=10, armor_heal=5, armor_use=250},
|
groups = {armor_feet=10, armor_heal=5, armor_use=250},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("3d_armor:boots_gold", {
|
minetest.register_tool("3d_armor:boots_gold", {
|
||||||
|
@ -131,6 +196,8 @@ minetest.register_tool("3d_armor:boots_gold", {
|
||||||
inventory_image = "3d_armor_inv_boots_gold.png",
|
inventory_image = "3d_armor_inv_boots_gold.png",
|
||||||
groups = {armor_feet=15, armor_heal=10, armor_use=500},
|
groups = {armor_feet=15, armor_heal=10, armor_use=500},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("3d_armor:boots_diamond",{
|
minetest.register_tool("3d_armor:boots_diamond",{
|
||||||
|
@ -138,6 +205,8 @@ minetest.register_tool("3d_armor:boots_diamond",{
|
||||||
inventory_image = "3d_armor_inv_boots_diamond.png",
|
inventory_image = "3d_armor_inv_boots_diamond.png",
|
||||||
groups = {armor_feet=20, armor_heal=15, armor_use=750},
|
groups = {armor_feet=20, armor_heal=15, armor_use=750},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("3d_armor:boots_chain", {
|
minetest.register_tool("3d_armor:boots_chain", {
|
||||||
|
@ -145,6 +214,8 @@ minetest.register_tool("3d_armor:boots_chain", {
|
||||||
inventory_image = "3d_armor_inv_boots_chain.png",
|
inventory_image = "3d_armor_inv_boots_chain.png",
|
||||||
groups = {armor_feet=15, armor_heal=10, armor_use=500},
|
groups = {armor_feet=15, armor_heal=10, armor_use=500},
|
||||||
wear = 0,
|
wear = 0,
|
||||||
|
on_place = wear_armor,
|
||||||
|
on_secondary_use = wear_armor,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Register Craft Recipies
|
-- Register Craft Recipies
|
||||||
|
|
Loading…
Reference in New Issue