mirror of
https://github.com/S4mpsa/InfOS.git
synced 2025-09-08 06:38:57 -04:00
Adding machine states to machine.lua
This commit is contained in:
parent
711d96108c
commit
fc6b6db776
@ -1,27 +1,40 @@
|
|||||||
-- Import section
|
-- Import section
|
||||||
local mock = require("data.mock.mock-energy-provider")
|
local mock = require("data.mock.mock-energy-provider")
|
||||||
EnergyProvider = require("data.datasource.energy-provider")
|
EnergyProvider = require("data.datasource.energy-provider")
|
||||||
|
MultiBlock = require("data.datasource.multi-block")
|
||||||
Inherits = require("utils.inherits")
|
Inherits = require("utils.inherits")
|
||||||
--
|
--
|
||||||
|
|
||||||
local machine = Inherits(EnergyProvider)
|
local machine = Inherits(EnergyProvider)
|
||||||
local machines = {}
|
local machines = {}
|
||||||
|
|
||||||
machine.types = {
|
machine.types = {
|
||||||
energy = "energy",
|
energy = "energy",
|
||||||
multiblock = "multiblock",
|
multiblock = "multiblock",
|
||||||
singleblock = "singleblock"
|
singleblock = "singleblock"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
machine.states = {
|
||||||
|
ON = {name = "ON", color = Colors.workingColor},
|
||||||
|
FULL = {name = "FULL", color = Colors.workingColor},
|
||||||
|
IDLE = {name = "IDLE", color = Colors.idleColor},
|
||||||
|
FILLING = {name = "FILLING", color = Colors.idleColor},
|
||||||
|
OFF = {name = "OFF", color = Colors.offColor},
|
||||||
|
DRAINING = {name = "DRAINING", color = Colors.offColor},
|
||||||
|
BROKEN = {name = "BROKEN", color = Colors.errorColor},
|
||||||
|
EMPTY = {name = "EMPTY", color = Colors.errorColor}
|
||||||
|
}
|
||||||
|
|
||||||
function machine.getMachine(address, name, type)
|
function machine.getMachine(address, name, type)
|
||||||
if machines[address] then
|
if machines[address] then
|
||||||
return machines[address]
|
return machines[address]
|
||||||
else
|
else
|
||||||
local mach = {}
|
local mach = {}
|
||||||
if type == machine.types.energy then
|
if type == machine.types.energy then
|
||||||
print(machine.name)
|
mach = EnergyProvider:new(address, name)
|
||||||
elseif type == machine.types.multiblock then
|
elseif type == machine.types.multiblock then
|
||||||
|
mach = MultiBlock:new(address, name)
|
||||||
end
|
end
|
||||||
mach = machine:new(address, name)
|
|
||||||
machines[address] = mach
|
machines[address] = mach
|
||||||
return mach
|
return mach
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user