forked from VoxeLibre/VoxeLibre
various codestyle fixes
This commit is contained in:
parent
16415ae577
commit
1e16647fe9
|
@ -10,7 +10,7 @@ for _, template_name in pairs(mcl_armor_trims.overlays) do
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = mod_registername .. template_name .. " 2",
|
output = mod_registername .. template_name .. " 2",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"mcl_core:diamond",modname .. ":" .. template_name,"mcl_core:diamond"},
|
{"mcl_core:diamond",mod_registername .. template_name,"mcl_core:diamond"},
|
||||||
{"mcl_core:diamond","mcl_core:cobble","mcl_core:diamond"},
|
{"mcl_core:diamond","mcl_core:cobble","mcl_core:diamond"},
|
||||||
{"mcl_core:diamond","mcl_core:diamond","mcl_core:diamond"},
|
{"mcl_core:diamond","mcl_core:diamond","mcl_core:diamond"},
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,19 +53,24 @@ local formspec = "size[9,9]" ..
|
||||||
"listring[context;input]"..
|
"listring[context;input]"..
|
||||||
"listring[current_player;main]"
|
"listring[current_player;main]"
|
||||||
|
|
||||||
|
local smithing_materials = {
|
||||||
|
["mcl_nether:netherite_ingot"] = "netherite",
|
||||||
|
["mcl_core:diamond"] = "diamond",
|
||||||
|
["mcl_core:lapis"] = "lapis",
|
||||||
|
["mcl_amethyst:amethyst_shard"] = "amethyst",
|
||||||
|
["mesecons:wire_00000000_off"] = "redstone",
|
||||||
|
["mcl_core:iron_ingot"] = "iron",
|
||||||
|
["mcl_core:gold_ingot"] = "gold",
|
||||||
|
["mcl_copper:copper_ingot"] = "copper",
|
||||||
|
["mcl_core:emerald"] = "emerald",
|
||||||
|
["mcl_nether:quartz"] = "quartz"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
local function upgrade_trimmed(itemstack, color_mineral, template)
|
local function upgrade_trimmed(itemstack, color_mineral, template)
|
||||||
--get information required
|
--get information required
|
||||||
local material_name = color_mineral:get_name()
|
local material_name = color_mineral:get_name()
|
||||||
if(string.find(material_name,"mesecons:")) then
|
material_name = smithing_materials[material_name]
|
||||||
material_name = "redstone"
|
|
||||||
else
|
|
||||||
material_name = material_name:gsub("_ingot","")
|
|
||||||
material_name = material_name:gsub("mcl_core:","")
|
|
||||||
material_name = material_name:gsub("mcl_nether:","")
|
|
||||||
material_name = material_name:gsub("mcl_amethyst:","")
|
|
||||||
material_name = material_name:gsub("_shard","")
|
|
||||||
material_name = material_name:gsub("mcl_copper:","")
|
|
||||||
end
|
|
||||||
|
|
||||||
local overlay = template:get_name():gsub("mcl_armor_trims:","")
|
local overlay = template:get_name():gsub("mcl_armor_trims:","")
|
||||||
|
|
||||||
|
@ -76,22 +81,8 @@ local function upgrade_trimmed(itemstack, color_mineral, template)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
local function is_smithing_mineral(itemname)
|
function mcl_smithing_table.is_smithing_mineral(itemname)
|
||||||
if itemname == "mcl_nether:netherite_ingot"
|
return smithing_materials[itemname] ~= nil
|
||||||
or itemname == "mcl_core:diamond"
|
|
||||||
or itemname == "mcl_core:lapis"
|
|
||||||
or itemname == "mcl_amethyst:amethyst_shard"
|
|
||||||
or itemname == "mesecons:wire_00000000_off"
|
|
||||||
or itemname == "mcl_core:iron_ingot"
|
|
||||||
or itemname == "mcl_core:gold_ingot"
|
|
||||||
or itemname == "mcl_copper:copper_ingot"
|
|
||||||
or itemname == "mcl_core:emerald"
|
|
||||||
or itemname == "mcl_nether:quartz"
|
|
||||||
then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function reset_upgraded_item(pos)
|
local function reset_upgraded_item(pos)
|
||||||
|
@ -104,7 +95,7 @@ local function reset_upgraded_item(pos)
|
||||||
|
|
||||||
if inv:get_stack("mineral", 1):get_name() == "mcl_nether:netherite_ingot" and not template_present then
|
if inv:get_stack("mineral", 1):get_name() == "mcl_nether:netherite_ingot" and not template_present then
|
||||||
upgraded_item = mcl_smithing_table.upgrade_item_netherite(inv:get_stack("upgrade_item", 1))
|
upgraded_item = mcl_smithing_table.upgrade_item_netherite(inv:get_stack("upgrade_item", 1))
|
||||||
elseif template_present and is_armor and not is_trimmed and is_smithing_mineral(inv:get_stack("mineral", 1):get_name()) then
|
elseif template_present and is_armor and not is_trimmed and mcl_smithing_table.is_smithing_mineral(inv:get_stack("mineral", 1):get_name()) then
|
||||||
upgraded_item = upgrade_trimmed(inv:get_stack("upgrade_item", 1),inv:get_stack("mineral", 1),inv:get_stack("template", 1))
|
upgraded_item = upgrade_trimmed(inv:get_stack("upgrade_item", 1),inv:get_stack("mineral", 1),inv:get_stack("template", 1))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -142,7 +133,17 @@ minetest.register_node("mcl_smithing_table:table", {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
if listname == "upgrade_item" and (mcl_smithing_table.upgrade_item_netherite(stack) or string.find(stack:get_name(),"mcl_armor:")) or listname == "mineral" and is_smithing_mineral(stack:get_name()) or listname == "template" and string.find(stack:get_name(),"mcl_armor_trims") then
|
if
|
||||||
|
listname == "upgrade_item"
|
||||||
|
and string.find(stack:get_name(),"mcl_armor:") -- allow any armor piece to go in (in case the player wants to trim them)
|
||||||
|
|
||||||
|
or listname == "mineral"
|
||||||
|
and mcl_smithing_table.is_smithing_mineral(stack:get_name())
|
||||||
|
|
||||||
|
or listname == "template"
|
||||||
|
and string.find(stack:get_name(),"mcl_armor_trims")
|
||||||
|
|
||||||
|
then
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue