Adjusting getMultiblockStatusUsecase

Returning status outside of a table
Using `isWorkAllowed` instead of an unexistent method
This commit is contained in:
Gabriel Moreira Minossi 2021-01-17 23:16:26 -03:00
parent 92c70b3e23
commit f1d77a7eee

View File

@ -1,6 +1,5 @@
-- Import section -- Import section
Machine = require("data.datasource.machine") Machine = require("data.datasource.machine")
Alarm = require("api.sound.alarm")
-- --
local function exec(address, name) local function exec(address, name)
@ -9,7 +8,7 @@ local function exec(address, name)
local problems = multiblock:getNumberOfProblems() local problems = multiblock:getNumberOfProblems()
local state = {} local state = {}
if multiblock:isMachineEnabled() then if multiblock:isWorkAllowed() then
if multiblock:hasWork() then if multiblock:hasWork() then
state = Machine.states.ON state = Machine.states.ON
else else
@ -24,12 +23,10 @@ local function exec(address, name)
end end
local totalProgress = multiblock:getProgress() local totalProgress = multiblock:getProgress()
local maxProgress = totalProgress.maximum
local progress = totalProgress.current
status[multiblock.name] = { status = {
progress = progress, progress = totalProgress.current,
maxProgress = maxProgress, maxProgress = totalProgress.maximum,
problems = problems, problems = problems,
probablyUses = multiblock:getEnergyUsage(), probablyUses = multiblock:getEnergyUsage(),
efficiencyPercentage = multiblock:getEfficiencyPercentage(), efficiencyPercentage = multiblock:getEfficiencyPercentage(),