monitor manager

This commit is contained in:
kepler155c
2017-09-24 16:19:19 -04:00
parent 09c1285132
commit 05166c1fd3
2 changed files with 23 additions and 22 deletions

View File

@@ -345,6 +345,7 @@ end
local function watchResources(items) local function watchResources(items)
local craftList = { } local craftList = { }
local outputs = { }
for k, res in pairs(resources) do for k, res in pairs(resources) do
local item = getItemWithQty(items, res, res.ignoreDamage) local item = getItemWithQty(items, res, res.ignoreDamage)
@@ -382,8 +383,19 @@ local function watchResources(items)
end end
if res.rsControl and res.rsDevice and res.rsSide then if res.rsControl and res.rsDevice and res.rsSide then
local enable = item.count < res.low
if not outputs[res.rsDevice] then
outputs[res.rsDevice] = { }
end
outputs[res.rsDevice][res.rsSide] = outputs[res.rsDevice][res.rsSide] or enable
end
end
for rsDevice, sides in pairs(outputs) do
for side, enable in pairs(sides) do
pcall(function() pcall(function()
device[res.rsDevice].setOutput(res.rsSide, item.count < res.low) debug({ rsDevice, side, enable })
device[rsDevice].setOutput(side, enable)
end) end)
end end
end end

View File

@@ -65,13 +65,7 @@ local function focusProcess(process)
lastFocused:focus(false) lastFocused:focus(false)
end end
for k,v in pairs(processes) do Util.removeByValue(processes, process)
if v == process then
table.remove(processes, k)
break
end
end
table.insert(processes, process) table.insert(processes, process)
process:focus(true) process:focus(true)
end end
@@ -132,12 +126,7 @@ function Process:new(args)
os.sleep(3) os.sleep(3)
end end
end end
for k,v in pairs(processes) do Util.removeByValue(processes, self)
if v == self then
table.remove(processes, k)
break
end
end
saveConfig() saveConfig()
redraw() redraw()
end) end)
@@ -243,7 +232,7 @@ function Process:resizeClick(x, y)
end end
self:reposition() self:reposition()
self:resume('term_resize') self:resume('term_resize')
self:drawSizers() self:drawSizers(true)
saveConfig() saveConfig()
end end
@@ -307,7 +296,7 @@ function defaultEnv.multishell.getCurrent()
end end
function defaultEnv.multishell.getCount() function defaultEnv.multishell.getCount()
return Util.size(processes) return #processes
end end
function defaultEnv.multishell.launch(env, file, ...) function defaultEnv.multishell.launch(env, file, ...)
@@ -328,12 +317,12 @@ end
local function addShell() local function addShell()
local process = setmetatable({ local process = setmetatable({
x = monDim.width - 8, x = monDim.width - 8,
y = monDim.height, y = monDim.height,
width = 9, width = 9,
height = 1, height = 1,
isShell = true, isShell = true,
uid = nextUID(), uid = nextUID(),
}, { __index = Process }) }, { __index = Process })
function process:focus(focused) function process:focus(focused)