Implement Sawmill
This commit is contained in:
@@ -19,6 +19,7 @@ industrialtest.api={
|
||||
compressorRecipes={},
|
||||
extractorRecipes={},
|
||||
cableFormerRecipes={},
|
||||
sawmillRecipeProviders={},
|
||||
geothermalGeneratorFuels={},
|
||||
waterMillFuels={},
|
||||
rotaryMaceratorModifiers={},
|
||||
|
||||
@@ -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: <name>, <calorificValue>, <storageItems>
|
||||
-- which is a table containing items which are tables with following keys: <name>, <leftover>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"),{
|
||||
{
|
||||
|
||||
+65
@@ -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,
|
||||
|
||||
@@ -909,6 +909,42 @@ local pages={
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
name="sawmill",
|
||||
title=S("Sawmill"),
|
||||
icon="industrialtest:sawmill",
|
||||
content={
|
||||
[[
|
||||
<big>||Sawmill||</big>
|
||||
<left>
|
||||
||Sawmill allows for transforming wood into planks and planks into sticks more efficiently. The byproduct of wood cutting is the <item name="industrialtest:saw_dust" height="{{ITEM_HEIGHT}}"> <b>Saw Dust</b>.||
|
||||
</left>
|
||||
]],
|
||||
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")),
|
||||
[[
|
||||
<img name="industrialtest_guide_sawmill.png" width="{{IMAGE_WIDTH}}">
|
||||
<left>||Picture 1. Sawmill cutting <item name="{{elementKeyWood}}" height="{{ITEM_HEIGHT}}"> <b>Oak Log</b>.||</left>
|
||||
]]
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
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
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -1459,4 +1459,20 @@ msgstr "Blok surowego irydu"
|
||||
|
||||
#: minerals.lua:42, minerals.lua:101
|
||||
msgid "Block of Iridium"
|
||||
msgstr "Blok irydu"
|
||||
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 <item name=\"industrialtest:saw_dust\" height=\"@1\"> <b>Saw Dust</b>."
|
||||
msgstr "Tartak pozwala na bardziej efektywne przetwarzanie drewna w deski i desek w patyki. Produktem ubocznym cięcia drewna są <item name=\"industrialtest:saw_dust\" height=\"@1\"> <b>Trociny</b>."
|
||||
|
||||
#: guide.lua:943
|
||||
msgid "Picture 1. Sawmill cutting <item name=\"@1\" height=\"@2\"> <b>Oak Log</b>."
|
||||
msgstr "Obraz 1. Tartak tnący <item name=\"@1\" height=\"@2\"> <b>Dębowy pień</b>."
|
||||
|
||||
@@ -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 <item name=\"industrialtest:saw_dust\" height=\"@1\"> <b>Saw Dust</b>."
|
||||
msgstr ""
|
||||
|
||||
#: guide.lua:943
|
||||
msgid "Picture 1. Sawmill cutting <item name=\"@1\" height=\"@2\"> <b>Oak Log</b>."
|
||||
msgstr ""
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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}
|
||||
}
|
||||
})
|
||||
@@ -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")
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 7.7 KiB |
Reference in New Issue
Block a user