Adding energy specific status

This commit is contained in:
Gabriel Moreira Minossi 2021-01-14 21:42:33 -03:00
parent 598cfeb95b
commit 6add69e5f8
4 changed files with 18 additions and 11 deletions

View File

@ -258,9 +258,7 @@ function widget.createPowerWidget(address)
local function getMiddleString(self) local function getMiddleString(self)
local time = self.timeToFull or self.timeToEmpty or 0 local time = self.timeToFull or self.timeToEmpty or 0
return (self.dProgress > 0 and "+" or "") .. return (self.dProgress >= 0 and " Full in: " or "Empty in: ") .. Utility.splitNumber(time) .. " s"
self.dProgress ..
" EU/s. " .. (self.dProgress >= 0 and " Full in: " or "Empty in: ") .. Utility.splitNumber(time) .. " s"
end end
local powerWidget = { local powerWidget = {

View File

@ -18,10 +18,11 @@ local output = math.random(16000)
function MockEnergyProvider.getSensorInformation() function MockEnergyProvider.getSensorInformation()
input = input + math.random(-100, 100) input = input + math.random(-100, 100)
output = input + math.random(-100, 100) output = input + math.random(-100, 100)
progress = progress + input - output > 0 and progress + input - output or 0
return { return {
"§9Insane Voltage Battery Buffer§r", "§9Insane Voltage Battery Buffer§r",
"Stored Items:", "Stored Items:",
"§a" .. Utility.splitNumber(progress + input - output) .. "§r EU / §e1,608,388,608§r EU", "§a" .. Utility.splitNumber(progress) .. "§r EU / §e1,608,388,608§r EU",
"Average input:", "Average input:",
Utility.splitNumber(input) .. " EU/t", Utility.splitNumber(input) .. " EU/t",
"Average output:", "Average output:",

View File

@ -1,15 +1,12 @@
-- Import section -- Import section
Machine = require("data.datasource.machines") Machine = require("data.datasource.machine")
-- --
local function exec(address, name) local function exec(address, name)
local energyBuffer = Machine.getMachine(address, name) local energyBuffer = Machine.getMachine(address, name, Machine.types.energy)
-- local comsumption = getConsumption(energyBuffer)
-- local production = getProduction(energyBuffer)
local consumption = energyBuffer:getAverageInput() local consumption = energyBuffer:getAverageInput()
local production = energyBuffer:getAverageOutput() local production = energyBuffer:getAverageOutput()
local state = {name = "ON", color = Colors.workingColor}
local changeRate = production - consumption local changeRate = production - consumption
local totalEnergy = energyBuffer:getTotalEnergy() local totalEnergy = energyBuffer:getTotalEnergy()
@ -18,6 +15,17 @@ local function exec(address, name)
local energyLimit = changeRate > 0 and maximumEnergy or 0 local energyLimit = changeRate > 0 and maximumEnergy or 0
local state = {}
if (currentEnergy == maximumEnergy) then
state = {name = changeRate .. " EU/s", color = Colors.workingColor}
elseif currentEnergy == 0 then
state = {name = changeRate .. " EU/s", color = Colors.errorColor}
elseif changeRate > 0 then
state = {name = "+" .. changeRate .. " EU/s", color = Colors.idleColor}
else
state = {name = changeRate .. " EU/s", color = Colors.offColor}
end
local timeToFull = changeRate > 0 and math.floor((energyLimit - currentEnergy) / changeRate) or nil local timeToFull = changeRate > 0 and math.floor((energyLimit - currentEnergy) / changeRate) or nil
local timeToEmpty = changeRate < 0 and math.floor((energyLimit - currentEnergy) / changeRate) or nil local timeToEmpty = changeRate < 0 and math.floor((energyLimit - currentEnergy) / changeRate) or nil

View File

@ -9,7 +9,7 @@ shell.execute("wget -fq " .. tarMan)
shell.setWorkingDirectory("/bin") shell.setWorkingDirectory("/bin")
shell.execute("wget -fq " .. tarBin) shell.execute("wget -fq " .. tarBin)
local InfOS = "https://github.com/gordominossi/InfOS/releases/download/v0.1/InfOS.tar" local InfOS = "https://github.com/gordominossi/InfOS/releases/download/v0.2/InfOS.tar"
shell.setWorkingDirectory("/home") shell.setWorkingDirectory("/home")
if not shell.resolve("/home/lib") then if not shell.resolve("/home/lib") then