Lazy commit: processing stations

This commit is contained in:
Van
2026-06-03 21:46:40 +03:00
parent 3854410041
commit 592bbf9c58
16 changed files with 266 additions and 185 deletions

View File

@@ -28,11 +28,10 @@ local ProcessingStation = BaseProcessingStation:extend({})
---@param def ProcessingStationDef
---@param nodesDef BaseProcessingStation.NodesDef
function ProcessingStation:new(name, def, nodesDef)
---@type ProcessingStation
local instance = self:getInstance(BaseProcessingStation:new(name, def, nodesDef))
instance.containerStation = ProcessingContainerStation:new(name, def, nodesDef)
instance.fuelStation = ProcessingFuelStation:new(name, def, nodesDef)
local instance = self:getInstance(BaseProcessingStation:new(name, def))
instance.containerStation = ProcessingContainerStation:new(name, def)
instance.fuelStation = ProcessingFuelStation:new(name, def)
local settings = nodesDef.settings
local activeSettings = nodesDef.activeSettings
@@ -63,21 +62,21 @@ function ProcessingStation:new(name, def, nodesDef)
callbacks.on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
oldCallback(pos, from_list, from_index, to_list, to_index, count, player)
instance:startTimer(pos)
instance.fuelStation:startTimer(pos)
end
oldCallback = callbacks.on_metadata_inventory_put or function(...) end
callbacks.on_metadata_inventory_put = function(pos, listname, index, stack, player)
oldCallback(pos, listname, index, stack, player)
instance:startTimer(pos)
instance.fuelStation:startTimer(pos)
end
oldCallback = callbacks.on_metadata_inventory_take or function(...) end
callbacks.on_metadata_inventory_take = function(pos, listname, index, stack, player)
oldCallback(pos, listname, index, stack, player)
instance:startTimer(pos)
instance.fuelStation:startTimer(pos)
end
oldCallback = callbacks.on_timer or function(...) end
@@ -100,7 +99,7 @@ function ProcessingStation:new(name, def, nodesDef)
return instance
end
---@param pos MapPosition
---@param pos MapVector
---@param elapsed number
---@param node NodeTable
---@param timeout number
@@ -108,12 +107,12 @@ end
function ProcessingStation:onTimer(pos, elapsed, node, timeout)
local meta = core.get_meta(pos)
local isProcessing, craft = self.containerStation:getCraft(true, meta, timeout)
core.log(tostring(isProcessing))
isProcessing = self.fuelStation:burnFuel(isProcessing, meta, timeout)
core.log(tostring(isProcessing))
isProcessing = self.containerStation:processing(isProcessing, meta, timeout, craft)
core.log(tostring(isProcessing))
local isProcessing, craft = self.containerStation:getCraft(true, meta)
isProcessing = self.fuelStation:burnFuel(isProcessing, meta, elapsed)
if craft ~= nil then
isProcessing = self.fuelStation:takeFuel(isProcessing, meta, elapsed)
end
isProcessing = self.containerStation:processing(isProcessing, meta, elapsed, craft)
self:swapNode(isProcessing, pos)
@@ -153,8 +152,8 @@ local tab = function(self, playerName, tabType)
:list(inventoryLocation, 'input', 1, 1, 1, 2)
:list(inventoryLocation, 'output', 3, 1, 1, 1)
:list(inventoryLocation, 'fuel', 1, 4, 1, 1)
:label(4, 3, tostring(meta:get_float('remaining_fuel')))
:label(4.5, 3, tostring(meta:get_float('processing_time')))
:label(4, 3, tostring(math.round(meta:get_float('remaining_fuel'))))
:label(4.5, 3, tostring(math.round(meta:get_float('processing_time'))))
return form
end
@@ -165,7 +164,8 @@ ProcessingStation:new('test_processing_node', {
inputSlots = 2,
fuelGroup = 'wood',
enableIdling = true,
enableRegression = true,
enableContainerProcessing = true,
--enableRegression = true,
},
{
settings = {