TheKojent icon

Turbo Tree Monitor

TheKojent | PRO | 12/29/14 09:09:08 PM UTC | 0 ⭐ | 310 👁️ | Never ⏰ | []
Lua |

1.09 KB

|

None

|

0 👍

/

0 👎

--[[
Monitoring system for the TurboTree network
Requires 1 computer, a 3 wide monitor array to the left, and 1 modem on the rear.
]]
 
m = peripheral.wrap("left") --Set up monitor
m.setTextScale(1.5)
m.clear()
 
rednet.open("back") --Set up router
 
local data = {{"logger1", "------", "away"}, {"sorter1", "------", "away"}, {"sorter2", "------", "away"}} --Set up data table with default values
 
local comp = {} --Table with adjusted computer IDs
comp[4] = 1
comp[12] = 2
comp[7] = 3
 
local function updateScreen()
    m.clear()
    for i =1,3 do
        m.setCursorPos(1,i)
        m.write(data[i][1] .. " " .. data[i][2] .. " " .. data[i][3])
    end
end
 
while true do
    updateScreen()
    id, message = rednet.receive()
    if id == 4 or id == 12 or id ==7 then
        if message == "home" or message == "away" then
            data[comp[id]][3] = message
        elseif tonumber(message) then
            local a = tonumber(message)
            if a >= 10 then
                data[comp[id]][2] = message .. "mins"
            elseif a == 1 then
                data[comp[id]][2] = " 1min "
            else
                data[comp[id]][2] = " " .. message .. "mins"
            end
        end
    end
end

Comments