Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Set params
- monitorSide = "top"
- modemSide = "right"
- m = peripheral.wrap(monitorSide)
- rednet.open(modemSide)
- m.setTextScale(1)
- m.setBackgroundColor(colors.black)
- m.clear()
- oldValues = {}
- --layout: name, id, loc_x, loc_y, length, storageType, color, displayName
- apps = {
- {"lava", 68, 1, 1, 39, "tank", colors.red, "Lava "},
- {"fuel", 54, 1, 2, 39, "tank", colors.yellow, "Fuel "},
- {"oil", 70, 1, 3, 39, "tank", colors.black, "Oil "},
- {"water", 71, 1, 4, 39, "tank", colors.blue, "Water"},
- {"MFSU", 73, 1, 5, 39, "power", colors.cyan, "Power"},
- {"steam", 140, 1, 6, 39, "tank", colors.gray, "Steam"},
- {"mobessence", 109, 1, 7, 39, "tank", colors.green, "Mob E"},
- {"immibis.liquidxp", 122, 1, 8, 39, "tank", colors.lime, "LXP "},
- {"seedoil", 141, 1, 9, 39, "tank", colors.brown, "Seed "},
- {"honey", 142, 1, 10, 39, "tank", colors.yellow, "Honey"},
- {"heliumplasma", 147, 1, 11, 39, "tank", colors.lightBlue, "H-Pla"},
- }
- --fill table with tables
- for _,v in ipairs(apps) do
- oldValues[v[1]] = {1,1}
- end
- function screen(loc_x, loc_y, length, storageType, color, displayName, name, amount, capacity)
- m.setTextScale(1.5)
- local space = " "
- m.setCursorPos(loc_x, loc_y)
- space = string.rep(space, length)
- m.write(space)
- m.setCursorPos(loc_x, loc_y)
- m.setBackgroundColor(color)
- if storageType == "ERROR" then
- m.write(storageType)
- elseif storageType == "mismatch" then
- m.write("names dont match, recheck computer id")
- else
- local percentage = 0
- local deltaTime, deltaAmount = 0, 0
- percentage = math.floor(amount / capacity * 100)
- local change = 0
- deltaTime = os.time() - oldValues[name][2]
- deltaAmount = amount - oldValues[name][1]
- change = deltaAmount / deltaTime
- change = math.floor(change / 1000)
- if change > 0 then
- change = "+"..tostring(change)
- end
- if storageType == "tank" then
- change = change.." mB/t"
- elseif storageType == "power" then
- change = change.." eu/t"
- end
- m.write(displayName..": "..change.." ("..percentage.."%)")
- oldValues[name] = {amount, os.time()}
- end
- m.setBackgroundColor(colors.black)
- end
- function split(msg)
- local values = {}
- number = 1
- for word in string.gmatch(msg, "%S+") do
- values[number] = word
- number = number + 1
- end
- return values[1], values[2], values[3]
- end
- function main()
- for _,j in ipairs(apps) do
- id, msg, distance = nil, nil, nil
- name, amount, capacity = nil, nil, nil
- rednet.send(j[2],"ping")
- id, msg, distance = rednet.receive(5)
- if id == j[2] then
- name, amount, capacity = split(msg)
- if name == j[1] then
- screen(j[3], j[4], j[5], j[6], j[7], j[8], name, amount, capacity)
- else
- screen(j[3], j[4], j[5], "mismatch", j[7])
- end
- end
- if id == nil then
- screen(j[3], j[4], j[5], "ERROR", j[7])
- end
- sleep(4)
- end
- end
- while true do
- main()
- sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement