This commit is contained in:
Thomas Rudin
2018-11-05 08:44:18 +01:00
parent 38a8e64627
commit b9d7a4e0b8
4 changed files with 107 additions and 94 deletions
+37
View File
@@ -0,0 +1,37 @@
minetest.register_craft({
output = "spacesuit:helmet",
recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:glass", "default:steel_ingot"},
{"wool:white", "default:steelblock", "wool:white"},
},
})
minetest.register_craft({
output = "spacesuit:chestplate",
recipe = {
{"default:steel_ingot", "default:mese", "default:steel_ingot"},
{"default:steel_ingot", "wool:white", "default:steel_ingot"},
{"default:steel_ingot", "wool:white", "default:steel_ingot"}
},
})
minetest.register_craft({
output = "spacesuit:pants",
recipe = {
{"default:steel_ingot", "wool:white", "default:steel_ingot"},
{"default:steel_ingot", "wool:white", "default:steel_ingot"},
{"wool:white", "wool:white", "wool:white"}
},
})
minetest.register_craft({
output = "spacesuit:boots",
recipe = {
{"default:steel_ingot", "wool:white", "default:steel_ingot"},
{"default:steel_ingot", "wool:white", "default:steel_ingot"},
{"default:steel_ingot", "default:steelblock", "default:steel_ingot"},
},
})
+33
View File
@@ -0,0 +1,33 @@
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime;
if timer >= 2 then
for _,player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name()
local name, armor_inv = armor.get_valid_player(armor, player, "[spacesuit]")
local has_helmet = armor_inv:contains_item("armor", "spacesuit:helmet")
local has_chestplate = armor_inv:contains_item("armor", "spacesuit:chestplate")
local has_pants = armor_inv:contains_item("armor", "spacesuit:pants")
local has_boots = armor_inv:contains_item("armor", "spacesuit:boots")
if has_helmet and has_chestplate and has_pants and has_boots and player:get_breath() < 10 then
for i, stack in pairs(armor_inv:get_list("armor")) do
if not stack:is_empty() then
local name = stack:get_name()
local use = minetest.get_item_group(name, "armor_use") or 0
armor:damage(player, i, stack, use)
end
end
player:set_breath(10)
end
end
timer = 0
end
end)
+8 -94
View File
@@ -1,101 +1,15 @@
spacesuit = {
armor_use = tonumber(minetest.settings:get("spacesuit.armor_use")) or 150,
}
armor:register_armor("spacesuit:helmet", { local MP = minetest.get_modpath("spacesuit")
description = "Spacesuit Helmet",
inventory_image = "spacesuit_inv_helmet.png",
groups = {armor_head=5, armor_heal=1, armor_use=150},
wear = 0,
})
minetest.register_tool("spacesuit:chestplate", { dofile(MP.."/suit.lua")
description = "Spacesuit Chestplate", dofile(MP.."/crafts.lua")
inventory_image = "spacesuit_inv_chestplate.png", dofile(MP.."/drowning.lua")
groups = {armor_torso=8, armor_heal=1, armor_use=150},
wear = 0,
})
minetest.register_tool("spacesuit:pants", {
description = "Spacesuit Pants",
inventory_image = "spacesuit_inv_pants.png",
groups = {armor_legs=7, armor_heal=1, armor_use=150},
wear = 0,
})
minetest.register_tool("spacesuit:boots", {
description = "Spacesuit Boots",
inventory_image = "spacesuit_inv_boots.png",
groups = {armor_feet=4, armor_heal=1, armor_use=150},
wear = 0,
})
minetest.register_craft({
output = "spacesuit:helmet",
recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:glass", "default:steel_ingot"},
{"wool:white", "default:steelblock", "wool:white"},
},
})
minetest.register_craft({
output = "spacesuit:chestplate",
recipe = {
{"default:steel_ingot", "default:mese", "default:steel_ingot"},
{"default:steel_ingot", "wool:white", "default:steel_ingot"},
{"default:steel_ingot", "wool:white", "default:steel_ingot"}
},
})
minetest.register_craft({
output = "spacesuit:pants",
recipe = {
{"default:steel_ingot", "wool:white", "default:steel_ingot"},
{"default:steel_ingot", "wool:white", "default:steel_ingot"},
{"wool:white", "wool:white", "wool:white"}
},
})
minetest.register_craft({
output = "spacesuit:boots",
recipe = {
{"default:steel_ingot", "wool:white", "default:steel_ingot"},
{"default:steel_ingot", "wool:white", "default:steel_ingot"},
{"default:steel_ingot", "default:steelblock", "default:steel_ingot"},
},
})
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime;
if timer >= 2 then
for _,player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name()
local name, armor_inv = armor.get_valid_player(armor, player, "[spacesuit]")
local has_helmet = armor_inv:contains_item("armor", "spacesuit:helmet")
local has_chestplate = armor_inv:contains_item("armor", "spacesuit:chestplate")
local has_pants = armor_inv:contains_item("armor", "spacesuit:pants")
local has_boots = armor_inv:contains_item("armor", "spacesuit:boots")
if has_helmet and has_chestplate and has_pants and has_boots and player:get_breath() < 10 then
for i, stack in pairs(armor_inv:get_list("armor")) do
if not stack:is_empty() then
local name = stack:get_name()
local use = minetest.get_item_group(name, "armor_use") or 0
armor:damage(player, i, stack, use)
end
end
player:set_breath(10)
end
end
timer = 0
end
end)
print("[OK] Spacesuit") print("[OK] Spacesuit")
+29
View File
@@ -0,0 +1,29 @@
armor:register_armor("spacesuit:helmet", {
description = "Spacesuit Helmet",
inventory_image = "spacesuit_inv_helmet.png",
groups = {armor_head=5, armor_heal=1, armor_use=spacesuit.armor_use},
wear = 0,
})
minetest.register_tool("spacesuit:chestplate", {
description = "Spacesuit Chestplate",
inventory_image = "spacesuit_inv_chestplate.png",
groups = {armor_torso=8, armor_heal=1, armor_use=spacesuit.armor_use},
wear = 0,
})
minetest.register_tool("spacesuit:pants", {
description = "Spacesuit Pants",
inventory_image = "spacesuit_inv_pants.png",
groups = {armor_legs=7, armor_heal=1, armor_use=spacesuit.armor_use},
wear = 0,
})
minetest.register_tool("spacesuit:boots", {
description = "Spacesuit Boots",
inventory_image = "spacesuit_inv_boots.png",
groups = {armor_feet=4, armor_heal=1, armor_use=spacesuit.armor_use},
wear = 0,
})