1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-06-28 14:16:06 +02:00

[3d_armor] Update

- Also fix a script
This commit is contained in:
LeMagnesium
2016-05-13 20:33:12 +02:00
parent d854e40ff9
commit 546500db7d
8 changed files with 239 additions and 121 deletions

View File

@ -2,8 +2,8 @@
===================================
Adds tin, silver and technic materials to 3d_armor.
Requires technic mod to be installed for craft registration.
Requires technic (technic_worldgen at least) mod.
Depends: 3d_armor
Depends: 3d_armor, technic_worldgen
Source code and textures by poet.nohit
Source code and textures by poet.nohit and numzero

2
mods/3d_armor/technic_armor/depends.txt Executable file → Normal file
View File

@ -1 +1,3 @@
3d_armor
technic_worldgen
moreores?

View File

@ -1,99 +1,56 @@
if minetest.get_modpath("technic") then
local stats = {
brass = { name="Brass", armor=1.8, heal=0, use=650 },
cast = { name="Cast Iron", armor=2.5, heal=0, use=200 },
carbon = { name="Carbon Steel", armor=2.7, heal=0, use=100 },
stainless = { name="Stainless Steel", armor=2.7, heal=0, use=75 },
}
local mats = {
brass="technic:brass_ingot",
cast="technic:cast_iron_ingot",
carbon="technic:carbon_steel_ingot",
stainless="technic:stainless_steel_ingot",
}
stats.tin = { name="Tin", armor=1.6, heal=0, use=750 }
stats.silver = { name="Silver", armor=1.8, heal=0, use=650 }
mats.tin = "default:tin_ingot"
mats.silver = "default:silver_ingot"
for k, v in pairs(stats) do
minetest.register_tool("technic_armor:helmet_"..k, {
description = v.name.." Helmet",
inventory_image = "technic_armor_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("technic_armor:chestplate_"..k, {
description = v.name.." Chestplate",
inventory_image = "technic_armor_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("technic_armor:leggings_"..k, {
description = v.name.." Leggings",
inventory_image = "technic_armor_inv_leggings_"..k..".png",
groups = {armor_legs=math.floor(7*v.armor), armor_heal=v.heal, armor_use=v.use},
wear = 0,
})
minetest.register_tool("technic_armor:boots_"..k, {
description = v.name.." Boots",
inventory_image = "technic_armor_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 = "technic_armor:helmet_"..k,
recipe = {
{v, v, v},
{v, "", v},
{"", "", ""},
},
})
minetest.register_craft({
output = "technic_armor:chestplate_"..k,
recipe = {
{v, "", v},
{v, v, v},
{v, v, v},
},
})
minetest.register_craft({
output = "technic_armor:leggings_"..k,
recipe = {
{v, v, v},
{v, "", v},
{v, "", v},
},
})
minetest.register_craft({
output = "technic_armor:boots_"..k,
recipe = {
{v, "", v},
{v, "", v},
},
})
end
if minetest.get_modpath("shields") then
for k, v in pairs(stats) do
minetest.register_tool("technic_armor:shield_"..k, {
description = v.name.." Shield",
inventory_image = "technic_armor_inv_shield_"..k..".png",
groups = {armor_shield=math.floor(5*v.armor), armor_heal=v.heal, armor_use=v.use},
wear = 0,
})
local m = mats[k]
minetest.register_craft({
output = "technic_armor:shield_"..k,
recipe = {
{m, m, m},
{m, m, m},
{"", m, ""},
},
})
end
end
local stats = {
lead = { name="Lead", material="technic:lead_ingot", armor=1.6, heal=0, use=500, radiation=80*1.1 },
brass = { name="Brass", material="technic:brass_ingot", armor=1.8, heal=0, use=650, radiation=43 },
cast = { name="Cast Iron", material="technic:cast_iron_ingot", armor=2.5, heal=8, use=200, radiation=40 },
carbon = { name="Carbon Steel", material="technic:carbon_steel_ingot", armor=2.7, heal=10, use=100, radiation=40 },
stainless = { name="Stainless Steel", material="technic:stainless_steel_ingot", armor=2.7, heal=10, use=75, radiation=40 },
}
if minetest.get_modpath("moreores") then
stats.tin = { name="Tin", material="moreores:tin_ingot", armor=1.6, heal=0, use=750, radiation=37 }
stats.silver = { name="Silver", material="moreores:silver_ingot", armor=1.8, heal=6, use=650, radiation=53 }
end
local parts = {
helmet = { place="head", name="Helmet", level=5, radlevel = 0.10, craft={{1,1,1},{1,0,1}} },
chestplate = { place="torso", name="Chestplate", level=8, radlevel = 0.35, craft={{1,0,1},{1,1,1},{1,1,1}} },
leggings = { place="legs", name="Leggings", level=7, radlevel = 0.15, craft={{1,1,1},{1,0,1},{1,0,1}} },
boots = { place="feet", name="Boots", level=4, radlevel = 0.10, craft={{1,0,1},{1,0,1}} },
}
if minetest.get_modpath("shields") then
parts.shield = { place="shield", name="Shield", level=5, radlevel=0.00, craft={{1,1,1},{1,1,1},{0,1,0}} }
end
-- Makes a craft recipe based on a template
-- template is a recipe-like table but indices are used instead of actual item names:
-- 0 means nothing, everything else is treated as an index in the materials table
local function make_recipe(template, materials)
local recipe = {}
for j, trow in ipairs(template) do
local rrow = {}
for i, tcell in ipairs(trow) do
if tcell == 0 then
rrow[i] = ""
else
rrow[i] = materials[tcell]
end
end
recipe[j] = rrow
end
return recipe
end
for key, armor in pairs(stats) do
for partkey, part in pairs(parts) do
local partname = "technic_armor:"..partkey.."_"..key
minetest.register_tool(partname, {
description = armor.name.." "..part.name,
inventory_image = "technic_armor_inv_"..partkey.."_"..key..".png",
groups = {["armor_"..part.place]=math.floor(part.level*armor.armor), armor_heal=armor.heal, armor_use=armor.use, armor_radiation=math.floor(part.radlevel*armor.radiation)},
wear = 0,
})
minetest.register_craft({
output = partname,
recipe = make_recipe(part.craft, {armor.material}),
})
end
end