diff --git a/api/common.lua b/api/common.lua index 1ae7982..d242fc5 100644 --- a/api/common.lua +++ b/api/common.lua @@ -19,6 +19,7 @@ industrialtest.api={ compressorRecipes={}, extractorRecipes={}, cableFormerRecipes={}, + sawmillRecipeProviders={}, geothermalGeneratorFuels={}, waterMillFuels={}, rotaryMaceratorModifiers={}, diff --git a/api/registration.lua b/api/registration.lua index 02ab63c..5044dbd 100644 --- a/api/registration.lua +++ b/api/registration.lua @@ -200,6 +200,13 @@ function industrialtest.api.getCableFormerRecipeResult(recipe) return industrialtest.api.cableFormerRecipes[recipe] end +-- \brief Registers function which provides recipes for sawmill +-- \param provider function +-- \returns nil +function industrialtest.api.registerSawmillRecipeProvider(provider) + table.insert(industrialtest.api.sawmillRecipeProviders,provider) +end + -- \brief Registers fuel that can be used in geothermal generator -- \param fuel Table with following keys: , , -- which is a table containing items which are tables with following keys: , diff --git a/compatibility.lua b/compatibility.lua index f361247..dac5768 100644 --- a/compatibility.lua +++ b/compatibility.lua @@ -481,6 +481,7 @@ if industrialtest.mclAvailable then industrialtest.elementKeys.stick="mcl_core:stick" industrialtest.elementKeys.flint="mcl_core:flint" industrialtest.elementKeys.snowball="mcl_throwing:snowball" + industrialtest.elementKeys.torch="mcl_core:torch" industrialtest.elementKeys.snowBlock="mcl_core:snowblock" industrialtest.elementKeys.string="mcl_mobitems:string" industrialtest.elementKeys.junglePlanks="mcl_core:junglewood" @@ -724,6 +725,7 @@ elseif industrialtest.mtgAvailable then industrialtest.elementKeys.stick="default:stick" industrialtest.elementKeys.flint="default:flint" industrialtest.elementKeys.snowball="default:snow" + industrialtest.elementKeys.torch="default:torch" industrialtest.elementKeys.snowBlock="default:snowblock" industrialtest.elementKeys.blueDye="dye:blue" industrialtest.elementKeys.yellowDust="dye:yellow" diff --git a/craftitems.lua b/craftitems.lua index e37aade..0eb663d 100644 --- a/craftitems.lua +++ b/craftitems.lua @@ -474,6 +474,8 @@ industrialtest.api.registerCompressorRecipe({ recipe="industrialtest:hydrated_coal_dust" }) +industrialtest.api.registerResourceDust("saw","Saw",{},"#4c4007",false) + -- Plates industrialtest.api.registerPlate("bronze_plate",S("Bronze Plate"),{ { diff --git a/crafts.lua b/crafts.lua index 6875e64..a855470 100644 --- a/crafts.lua +++ b/crafts.lua @@ -75,6 +75,71 @@ if industrialtest.mclAvailable then }) end +-- Sawmill recipe providers +industrialtest.api.registerSawmillRecipeProvider(function(itemstack) + local srcAfter=ItemStack(itemstack:get_name()) + srcAfter:set_count(itemstack:get_count()-1) + if minetest.get_item_group(itemstack:get_name(),"tree")>0 then + local treeMapping={} + if industrialtest.mtgAvailable then + treeMapping={ + ["default:tree"]="default:wood", + ["default:jungletree"]="default:junglewood", + ["default:pine_tree"]="default:pine_wood", + ["default:acacia_tree"]="default:acacia_wood", + ["default:aspen_tree"]="default:aspen_wood" + } + elseif industrialtest.mclAvailable then + treeMapping={ + ["mcl_trees:tree_oak"]="mcl_trees:wood_oak", + ["mcl_trees:tree_dark_oak"]="mcl_trees:wood_dark_oak", + ["mcl_trees:tree_jungle"]="mcl_trees:wood_jungle", + ["mcl_trees:tree_spruce"]="mcl_trees:wood_spruce", + ["mcl_trees:tree_acacia"]="mcl_trees:wood_acacia", + ["mcl_trees:tree_birch"]="mcl_trees:wood_birch", + ["mcl_trees:bark_oak"]="mcl_trees:wood_oak", + ["mcl_trees:bark_dark_oak"]="mcl_trees:wood_dark_oak", + ["mcl_trees:bark_jungle"]="mcl_trees:wood_jungle", + ["mcl_trees:bark_spruce"]="mcl_trees:wood_spruce", + ["mcl_trees:bark_acacia"]="mcl_trees:wood_acacia", + ["mcl_trees:bark_birch"]="mcl_trees:wood_birch" + } + end + local woodNode=treeMapping[itemstack:get_name()] + if not woodNode then + return nil + end + return { + item={ + ItemStack(woodNode.." 5"), + ItemStack("industrialtest:saw_dust 2") + }, + time=3, + src=srcAfter + } + end + if minetest.get_item_group(itemstack:get_name(),"wood")>0 then + return { + item={ + ItemStack(industrialtest.elementKeys.stick.." 4"), + ItemStack("industrialtest:saw_dust 2") + }, + time=2, + src=srcAfter + } + end + return nil +end) + +minetest.register_craft({ + type="shaped", + output=industrialtest.elementKeys.torch.." 2", + recipe={ + {"industrialtest:saw_dust"}, + {industrialtest.elementKeys.stick} + } +}) + -- Geothermal Generator fuels industrialtest.api.registerGeothermalGeneratorFuel({ name=industrialtest.elementKeys.lavaSource, diff --git a/guide.lua b/guide.lua index 52d8a04..0101e46 100644 --- a/guide.lua +++ b/guide.lua @@ -909,6 +909,42 @@ local pages={ } }, + { + name="sawmill", + title=S("Sawmill"), + icon="industrialtest:sawmill", + content={ + [[ + ||Sawmill|| + + ||Sawmill allows for transforming wood into planks and planks into sticks more efficiently. The byproduct of wood cutting is the Saw Dust.|| + + ]], + createMachineInformationTable({ + { + name="inputVoltage", + value="LV" + }, + { + name="recipe", + value="Wood cutting" + }, + { + name="powerCapacity", + value=string.format("%d EU", industrialtest.Sawmill.capacity) + }, + { + name="opPower", + value=string.format("%d EU", industrialtest.Sawmill.opPower) + } + },S("Sawmill")), + [[ + + ||Picture 1. Sawmill cutting Oak Log.|| + ]] + } + }, + { name="solarPanels", title=S("Solar panels"), @@ -1946,7 +1982,8 @@ local function getGuideFormspec(playerName,pageName) elementKeyIronPickaxe=industrialtest.elementKeys.ironPickaxe, elementKeyStickyResin=industrialtest.elementKeys.stickyResin, elementKeyRubber=industrialtest.elementKeys.rubber, - elementKeyRubberWood=industrialtest.elementKeys.rubberWood + elementKeyRubberWood=industrialtest.elementKeys.rubberWood, + elementKeyWood=industrialtest.elementKeys.wood }) table.insert(formspec,string.format("hypertext[4.2,0.4;10.7,10.3;content;%s]",content)) break diff --git a/init.lua b/init.lua index adf4f66..2d37a07 100644 --- a/init.lua +++ b/init.lua @@ -66,6 +66,7 @@ dofile(modpath.."/machines/recycler.lua") dofile(modpath.."/machines/rotary_macerator.lua") dofile(modpath.."/machines/tool_workshop.lua") dofile(modpath.."/machines/transformer.lua") +dofile(modpath.."/machines/sawmill.lua") dofile(modpath.."/machines/solar_panel_generator.lua") dofile(modpath.."/machines/wind_mill.lua") diff --git a/locale/industrialtest.pl.po b/locale/industrialtest.pl.po index 66e93e7..06da49f 100644 --- a/locale/industrialtest.pl.po +++ b/locale/industrialtest.pl.po @@ -1459,4 +1459,20 @@ msgstr "Blok surowego irydu" #: minerals.lua:42, minerals.lua:101 msgid "Block of Iridium" -msgstr "Blok irydu" \ No newline at end of file +msgstr "Blok irydu" + +#: machines/sawmill.lua:20, guide.lua:914, guide.lua:918, guide.lua:940 +msgid "Sawmill" +msgstr "Tartak" + +#: craftitems.lua:477 +msgid "Saw Dust" +msgstr "Trociny" + +#: guide.lua.920 +msgid "Sawmill allows for transforming wood into planks and planks into sticks more efficiently. The byproduct of wood cutting is the Saw Dust." +msgstr "Tartak pozwala na bardziej efektywne przetwarzanie drewna w deski i desek w patyki. Produktem ubocznym cięcia drewna są Trociny." + +#: guide.lua:943 +msgid "Picture 1. Sawmill cutting Oak Log." +msgstr "Obraz 1. Tartak tnący Dębowy pień." diff --git a/locale/industrialtest.pot b/locale/industrialtest.pot index a605088..dd6c421 100644 --- a/locale/industrialtest.pot +++ b/locale/industrialtest.pot @@ -1460,3 +1460,19 @@ msgstr "" #: minerals.lua:42, minerals.lua:101 msgid "Block of Iridium" msgstr "" + +#: machines/sawmill.lua:20, guide.lua:914, guide.lua:918, guide.lua:940 +msgid "Sawmill" +msgstr "" + +#: craftitems.lua:477 +msgid "Saw Dust" +msgstr "" + +#: guide.lua.920 +msgid "Sawmill allows for transforming wood into planks and planks into sticks more efficiently. The byproduct of wood cutting is the Saw Dust." +msgstr "" + +#: guide.lua:943 +msgid "Picture 1. Sawmill cutting Oak Log." +msgstr "" diff --git a/machines/sawmill.lua b/machines/sawmill.lua new file mode 100644 index 0000000..74d1753 --- /dev/null +++ b/machines/sawmill.lua @@ -0,0 +1,73 @@ +-- IndustrialTest +-- Copyright (C) 2026 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") +industrialtest.Sawmill=industrialtest.internal.derive(industrialtest.SimpleElectricItemProcessor,{ + name="industrialtest:sawmill", + description=S("Sawmill"), + tiles={ + "industrialtest_machine_block.png", + "industrialtest_machine_block.png", + "industrialtest_machine_block.png", + "industrialtest_machine_block.png", + "industrialtest_machine_block.png", + "industrialtest_machine_block.png^industrialtest_sawmill_front.png" + }, + requiresWrench=true, + active={ + tiles={ + "industrialtest_machine_block.png", + "industrialtest_machine_block.png", + "industrialtest_machine_block.png", + "industrialtest_machine_block.png", + "industrialtest_machine_block.png", + "industrialtest_machine_block.png^industrialtest_sawmill_front_active.png" + } + }, + suplStorageLists={ + "sawdust" + }, + capacity=industrialtest.api.lvPowerFlow*2, + flow=industrialtest.api.lvPowerFlow, + opPower=50, + efficiency=0.5 +}) + +function industrialtest.Sawmill.getCraftResult(self,itemstack) + for _,provider in ipairs(industrialtest.api.sawmillRecipeProviders) do + local result=provider(itemstack) + if result then + return result + end + end + return { + item="", + time=0, + src=ItemStack(itemstack:get_name()) + } +end + +industrialtest.Sawmill:register() + +minetest.register_craft({ + type="shaped", + output="industrialtest:sawmill", + recipe={ + {"",industrialtest.elementKeys.ironIngot,""}, + {industrialtest.elementKeys.stick,"industrialtest:machine_block",industrialtest.elementKeys.stick}, + {industrialtest.elementKeys.tinIngot,"industrialtest:electronic_circuit",industrialtest.elementKeys.tinIngot} + } +}) diff --git a/machines/simple_electric_item_processor.lua b/machines/simple_electric_item_processor.lua index 5983b15..75dfda7 100644 --- a/machines/simple_electric_item_processor.lua +++ b/machines/simple_electric_item_processor.lua @@ -40,6 +40,11 @@ function industrialtest.SimpleElectricItemProcessor.onConstruct(self,pos) local inv=meta:get_inventory() inv:set_size("src",1) inv:set_size("dst",1) + if self.suplStorageLists then + for _,list in ipairs(self.suplStorageLists) do + inv:set_size(list,1) + end + end inv:set_size("powerStorage",1) inv:set_size("upgrades",4) meta:set_float("srcTime",-1) @@ -65,6 +70,7 @@ function industrialtest.SimpleElectricItemProcessor.getFormspec(self,pos) or "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"), industrialtest.internal.getItemSlotBg(6.4,2.8,1,1), "list[context;dst;6.4,2.8;1,1]", + self:getSuplStorageFormspec(), industrialtest.internal.getItemSlotBg(9,0.9,1,4), "list[context;upgrades;9,0.9;1,4]", "listring[context;src]", @@ -105,8 +111,15 @@ function industrialtest.SimpleElectricItemProcessor.onMetadataInventoryMove(self meta:set_float("srcTime",-1) meta:set_float("maxSrcTime",0) self:updateFormspec(pos) - elseif fromList=="dst" and dstSlot:get_free_space()>0 then - self:triggerIfNeeded(pos) + end + local outputLists=self:getOutputLists() + for _,outputList in ipairs(outputLists) do + if outputList==fromList then + local slot=inv:get_stack(outputList,1) + if slot:get_free_space()>0 then + self:triggerIfNeeded(pos) + end + end end end @@ -120,13 +133,19 @@ function industrialtest.SimpleElectricItemProcessor.onMetadataInventoryTake(self local meta=minetest.get_meta(pos) local inv=meta:get_inventory() local srcSlot=inv:get_stack("src",1) - local dstSlot=inv:get_stack("dst",1) if listname=="src" and srcSlot:is_empty() then meta:set_float("srcTime",-1) meta:set_float("maxSrcTime",0) self:updateFormspec(pos) - elseif listname=="dst" and dstSlot:get_free_space()>0 then - self:triggerIfNeeded(pos) + end + local outputLists=self:getOutputLists() + for _,outputList in ipairs(outputLists) do + if outputList==listname then + local slot=inv:get_stack(outputList,1) + if slot:get_free_space()>0 then + self:triggerIfNeeded(pos) + end + end end end @@ -152,7 +171,7 @@ function industrialtest.SimpleElectricItemProcessor.shouldActivate(self,pos) local srcSlot=inv:get_stack("src",1) if srcSlot:get_count()>0 then local output=self:getCraftResult(srcSlot) - return output and output.time>0 and inv:room_for_item("dst",output.item) + return output and output.time>0 and self:roomForOutput(inv,output.item) end return meta:contains("recipeOverride") and meta:contains("recipeOverrideMaxTime") and meta:get_string("recipeOverride")~="" @@ -178,7 +197,7 @@ function industrialtest.SimpleElectricItemProcessor.shouldDeactivate(self,pos) end local output=self:getCraftResult(srcSlot) - return not output or output.time==0 or not inv:room_for_item("dst",output.item) + return not output or output.time==0 or not self:roomForOutput(inv,output.item) end function industrialtest.SimpleElectricItemProcessor.activeUpdate(self,pos,elapsed,meta,inv) @@ -219,9 +238,16 @@ function industrialtest.SimpleElectricItemProcessor.activeUpdate(self,pos,elapse if srcSlot:get_count()>=speed*usedItems then multiplier=speed end - if output.item:get_count()>0 then - output.item:set_count(output.item:get_count()*multiplier) - inv:add_item("dst",output.item) + local outputs=type(output.item)=="userdata" and {output.item} or output.item + local lists=self:getOutputLists() + for i,output in ipairs(outputs) do + if i>#lists then + break + end + if output:get_count()>0 then + output:set_count(output:get_count()*multiplier) + inv:add_item(lists[i],output) + end end srcSlot:set_count(srcSlot:get_count()-multiplier*usedItems) inv:set_stack("src",1,srcSlot) @@ -233,6 +259,42 @@ function industrialtest.SimpleElectricItemProcessor.activeUpdate(self,pos,elapse return true end +function industrialtest.SimpleElectricItemProcessor.getOutputLists(self) + local lists=table.copy(self.suplStorageLists) + table.insert(lists,1,"dst") + return lists +end + +function industrialtest.SimpleElectricItemProcessor.getSuplStorageFormspec(self) + if not self.suplStorageLists then + return "" + end + local formspec={} + local slotY=2.8 + for i,list in ipairs(self.suplStorageLists) do + local slotX=6.4+i+i*0.1 + table.insert(formspec,industrialtest.internal.getItemSlotBg(slotX,slotY,1,1)) + table.insert(formspec,string.format("list[context;%s;%f,%f;1,1]",list,slotX,slotY)) + end + return table.concat(formspec,"") +end + +function industrialtest.SimpleElectricItemProcessor.roomForOutput(self,inv,outputItem) + if type(outputItem)=="userdata" then + return inv:room_for_item("dst",outputItem) + end + local lists=self:getOutputLists() + for i,itemstack in ipairs(outputItem) do + if i>#lists then + return false + end + if not inv:room_for_item(lists[i],itemstack) then + return false + end + end + return true +end + function industrialtest.SimpleElectricItemProcessor.isRecipeOverride(meta) if meta:contains("recipeOverride") and meta:contains("recipeOverrideMaxTime") and meta:get_string("recipeOverride")~="" then return meta:get_string("recipeOverride") diff --git a/textures/industrialtest_guide_sawmill.png b/textures/industrialtest_guide_sawmill.png new file mode 100644 index 0000000..12d82fc Binary files /dev/null and b/textures/industrialtest_guide_sawmill.png differ