From d268618cff9448efddd69ab033a36b31fe30489e Mon Sep 17 00:00:00 2001 From: mrkubax10 Date: Sat, 4 Mar 2023 16:01:06 +0100 Subject: [PATCH] Add refined iron, machine block and generator craft --- compatibility.lua | 6 ++++++ craftitems.lua | 18 ++++++++++++++++++ init.lua | 3 ++- machines.lua | 27 +++++++++++++++++++++++++++ nodes.lua | 40 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 nodes.lua diff --git a/compatibility.lua b/compatibility.lua index d45ad6a..ff7e981 100644 --- a/compatibility.lua +++ b/compatibility.lua @@ -461,6 +461,7 @@ if industrialtest.mclAvailable then } }) end + industrialtest.gameTexturePrefix="mcl" -- FIXME: Formspecs when used with MCL are misaligned, to fix that and also preserve compatibilty -- with MTG MCL has to stop using legacy formspec coordinates ~mrkubax10 industrialtest.formspecVersion=function() @@ -474,7 +475,9 @@ if industrialtest.mclAvailable then end -- assign element keys for elements that are required later industrialtest.elementKeys.stick="mcl_core:stick" + industrialtest.elementKeys.ironIngot="mcl_core:iron_ingot" industrialtest.elementKeys.powerCarrier="mesecons:mesecon" + industrialtest.elementKeys.furnace="mcl_furnaces:furnace" -- register required minerals that are not available in MCL industrialtest.registerMetal("tin","Tin",3,3) @@ -630,10 +633,13 @@ elseif industrialtest.mtgAvailable then industrialtest.formspecPlayerInv=function() return "list[current_player;main;0.5,6.25;8,1]list[current_player;main;0.5,7.5;8,3;8]" end + industrialtest.gameTexturePrefix="mtg" industrialtest.elementKeys.tinIngot="default:tin_ingot" industrialtest.elementKeys.bronzeIngot="default:bronze_ingot" + industrialtest.elementKeys.ironIngot="default:steel_ingot" industrialtest.elementKeys.stick="default:stick" industrialtest.elementKeys.powerCarrier="default:mese_crystal_fragment" + industrialtest.elementKeys.furnace="default:furnace" else error("No compatible games found!") end diff --git a/craftitems.lua b/craftitems.lua index c8eb45f..457a764 100644 --- a/craftitems.lua +++ b/craftitems.lua @@ -35,6 +35,24 @@ minetest.register_craft({ } }) +-- Other resources +minetest.register_craftitem("industrialtest:refined_iron_ingot",{ + description=S("Refined Iron Ingot"), + inventory_image="industrialtest_"..industrialtest.gameTexturePrefix.."_refined_iron_ingot.png", +}) +minetest.register_craft({ + type="cooking", + output="industrialtest:refined_iron_ingot", + recipe=industrialtest.elementKeys.ironIngot +}) +minetest.register_craft({ + type="shapeless", + output="industrialtest:refined_iron_ingot 8", + recipe={ + "industrialtest:machine_block" + } +}) + -- Item callbacks minetest.register_on_player_inventory_action(function(player,action,inventory,info) if action=="put" then diff --git a/init.lua b/init.lua index 1519b41..d4f8cba 100644 --- a/init.lua +++ b/init.lua @@ -25,4 +25,5 @@ dofile(modpath.."/compatibility.lua") dofile(modpath.."/api.lua") dofile(modpath.."/minerals.lua") dofile(modpath.."/machines.lua") -dofile(modpath.."/craftitems.lua") \ No newline at end of file +dofile(modpath.."/craftitems.lua") +dofile(modpath.."/nodes.lua") diff --git a/machines.lua b/machines.lua index bdbb50f..9cc12c3 100644 --- a/machines.lua +++ b/machines.lua @@ -139,3 +139,30 @@ elseif industrialtest.mclAvailable then definition._mcl_hardness=3.9 end minetest.register_node("industrialtest:generator",definition) +minetest.register_craft({ + type="shaped", + output="industrialtest:generator", + recipe={ + {"industrialtest:re_battery","",""}, + {"industrialtest:machine_block","",""}, + {industrialtest.elementKeys.furnace,"",""} + } +}) +minetest.register_craft({ + type="shaped", + output="industrialtest:generator", + recipe={ + {"","industrialtest:re_battery",""}, + {"","industrialtest:machine_block",""}, + {"",industrialtest.elementKeys.furnace,""} + } +}) +minetest.register_craft({ + type="shaped", + output="industrialtest:generator", + recipe={ + {"","","industrialtest:re_battery"}, + {"","","industrialtest:machine_block"}, + {"","",industrialtest.elementKeys.furnace} + } +}) diff --git a/nodes.lua b/nodes.lua new file mode 100644 index 0000000..8da0b9a --- /dev/null +++ b/nodes.lua @@ -0,0 +1,40 @@ +-- IndustrialTest +-- Copyright (C) 2023 mrkubax10 + +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. + +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. + +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +local S=minetest.get_translator("industrialtest") + +local definition={ + description=S("Machine Block"), + tiles={"industrialtest_machine_block.png"}, +} +if industrialtest.mtgAvailable then + definition.sound=default.node_sound_metal_defaults() + definition.groups={cracky=1,level=2} +elseif industrialtest.mclAvailable then + definition.sound=mcl_sounds.node_sound_metal_defaults() + definition._mcl_blast_resistance=6 + definition._mcl_hardness=5 +end +minetest.register_node("industrialtest:machine_block",definition) +minetest.register_craft({ + type="shaped", + output="industrialtest:machine_block", + recipe={ + {"industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot"}, + {"industrialtest:refined_iron_ingot","","industrialtest:refined_iron_ingot"}, + {"industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot","industrialtest:refined_iron_ingot"} + } +})