diff --git a/depends.txt b/depends.txt index b6cac21..585cc7a 100644 --- a/depends.txt +++ b/depends.txt @@ -1 +1,2 @@ +default 3d_armor diff --git a/init.lua b/init.lua index 305ead2..6c34633 100644 --- a/init.lua +++ b/init.lua @@ -1,83 +1,93 @@ -if minetest.get_modpath("default") then - local stats = { - space = { name="Space", armor=1, heal=0, use=75 }, - } - local mats = { - --PLACEHOLDER - space="default:dirt", - } - for k, v in pairs(stats) do - minetest.register_tool("moontest_spacesuit:helmet_"..k, { - description = v.name.." Helmet", - inventory_image = "moontest_spacesuit_inv_helmet_"..k..".png", - groups = {armor_head=math.floor(5*v.armor), armor_heal=v.heal, armor_use=v.use}, - wear = 0, - }) - minetest.register_tool("moontest_spacesuit:chestplate_"..k, { - description = v.name.." Chestplate", - inventory_image = "moontest_spacesuit_inv_chestplate_"..k..".png", - groups = {armor_torso=math.floor(8*v.armor), armor_heal=v.heal, armor_use=v.use}, - wear = 0, - }) - minetest.register_tool("moontest_spacesuit:pants_"..k, { - description = v.name.." Pants", - inventory_image = "moontest_spacesuit_inv_pants_"..k..".png", - groups = {armor_legs=math.floor(7*v.armor), armor_heal=v.heal, armor_use=v.use}, - wear = 0, - }) - minetest.register_tool("moontest_spacesuit:boots_"..k, { - description = v.name.." Boots", - inventory_image = "moontest_spacesuit_inv_boots_"..k..".png", - groups = {armor_feet=math.floor(4*v.armor), armor_heal=v.heal, armor_use=v.use}, - wear = 0, - }) - end - for k, v in pairs(mats) do - minetest.register_craft({ - output = "moontest_spacesuit:helmet_"..k, - recipe = { - {v, v, v}, - {v, "", v}, - {"", "", ""}, - }, - }) - minetest.register_craft({ - output = "moontest_spacesuit:chestplate_"..k, - recipe = { - {v, "", v}, - {v, v, v}, - {v, v, v}, - }, - }) - minetest.register_craft({ - output = "moontest_spacesuit:pants_"..k, - recipe = { - {v, v, v}, - {v, "", v}, - {v, "", v}, - }, - }) - minetest.register_craft({ - output = "moontest_spacesuit:boots_"..k, - recipe = { - {v, "", v}, - {v, "", v}, - }, - }) - end -end ---currently broken +minetest.register_tool("spacesuit:helmet", { + description = "Spacesuit Helmet", + inventory_image = "spacesuit_inv_helmet.png", + groups = {armor_head=5, armor_heal=1, armor_use=75}, + 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=75}, + 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=75}, + 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=75}, + 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) - for _, player in ipairs(minetest.get_connected_players()) do - if math.random() < 0.1 then -- spacesuit restores breath + timer = timer + dtime; + if timer >= 2 then + + for _,player in ipairs(minetest.get_connected_players()) do local name = player:get_player_name() local inv = player:get_inventory() - if inv:contains_item("armor", "moontest_spacesuit:helmet_space") and inv:contains_item("armor", "moontest_spacesuit:chestplate_space") and inv:contains_item("armor", "moontest_spacesuit:pants_space") and inv:contains_item("armor", "moontest_spacesuit:boots_space") then + + 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 then player:set_breath(10) end end + timer = 0 end -end) \ No newline at end of file +end) + + +print("[OK] Spacesuit") \ No newline at end of file diff --git a/textures/moontest_spacesuit_boots_space.png b/textures/spacesuit_boots.png similarity index 100% rename from textures/moontest_spacesuit_boots_space.png rename to textures/spacesuit_boots.png diff --git a/textures/moontest_spacesuit_boots_space_preview.png b/textures/spacesuit_boots_preview.png similarity index 100% rename from textures/moontest_spacesuit_boots_space_preview.png rename to textures/spacesuit_boots_preview.png diff --git a/textures/moontest_spacesuit_chestplate_space.png b/textures/spacesuit_chestplate.png similarity index 100% rename from textures/moontest_spacesuit_chestplate_space.png rename to textures/spacesuit_chestplate.png diff --git a/textures/moontest_spacesuit_chestplate_space_preview.png b/textures/spacesuit_chestplate_preview.png similarity index 100% rename from textures/moontest_spacesuit_chestplate_space_preview.png rename to textures/spacesuit_chestplate_preview.png diff --git a/textures/moontest_spacesuit_helmet_space.png b/textures/spacesuit_helmet.png similarity index 100% rename from textures/moontest_spacesuit_helmet_space.png rename to textures/spacesuit_helmet.png diff --git a/textures/moontest_spacesuit_helmet_space_preview.png b/textures/spacesuit_helmet_preview.png similarity index 100% rename from textures/moontest_spacesuit_helmet_space_preview.png rename to textures/spacesuit_helmet_preview.png diff --git a/textures/moontest_spacesuit_inv_boots_space.png b/textures/spacesuit_inv_boots.png similarity index 100% rename from textures/moontest_spacesuit_inv_boots_space.png rename to textures/spacesuit_inv_boots.png diff --git a/textures/moontest_spacesuit_inv_chestplate_space.png b/textures/spacesuit_inv_chestplate.png similarity index 100% rename from textures/moontest_spacesuit_inv_chestplate_space.png rename to textures/spacesuit_inv_chestplate.png diff --git a/textures/moontest_spacesuit_inv_helmet_space.png b/textures/spacesuit_inv_helmet.png similarity index 100% rename from textures/moontest_spacesuit_inv_helmet_space.png rename to textures/spacesuit_inv_helmet.png diff --git a/textures/moontest_spacesuit_inv_pants_space.png b/textures/spacesuit_inv_pants.png similarity index 100% rename from textures/moontest_spacesuit_inv_pants_space.png rename to textures/spacesuit_inv_pants.png diff --git a/textures/moontest_spacesuit_pants_space.png b/textures/spacesuit_pants.png similarity index 100% rename from textures/moontest_spacesuit_pants_space.png rename to textures/spacesuit_pants.png diff --git a/textures/moontest_spacesuit_pants_space_preview.png b/textures/spacesuit_pants_preview.png similarity index 100% rename from textures/moontest_spacesuit_pants_space_preview.png rename to textures/spacesuit_pants_preview.png