mirror of
https://github.com/S4mpsa/InfOS.git
synced 2025-08-04 02:16:05 -04:00

Returning status outside of a table Using `isWorkAllowed` instead of an unexistent method
39 lines
954 B
Lua
Executable File
39 lines
954 B
Lua
Executable File
-- Import section
|
|
Machine = require("data.datasource.machine")
|
|
--
|
|
|
|
local function exec(address, name)
|
|
local multiblock = Machine.getMachine(address, name, Machine.types.multiblock)
|
|
local status = {}
|
|
local problems = multiblock:getNumberOfProblems()
|
|
|
|
local state = {}
|
|
if multiblock:isWorkAllowed() then
|
|
if multiblock:hasWork() then
|
|
state = Machine.states.ON
|
|
else
|
|
state = Machine.states.IDLE
|
|
end
|
|
else
|
|
state = Machine.states.OFF
|
|
end
|
|
|
|
if problems > 0 then
|
|
state = Machine.states.BROKEN
|
|
end
|
|
|
|
local totalProgress = multiblock:getProgress()
|
|
|
|
status = {
|
|
progress = totalProgress.current,
|
|
maxProgress = totalProgress.maximum,
|
|
problems = problems,
|
|
probablyUses = multiblock:getEnergyUsage(),
|
|
efficiencyPercentage = multiblock:getEfficiencyPercentage(),
|
|
state = state
|
|
}
|
|
return status
|
|
end
|
|
|
|
return exec
|