Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function periUptd()
- tanks = {{},{}} -- Number of '{}' must match the number of liquids
- -- Create adress array
- -- tanks[ liquidNumber ][ tankNumber ] = peripheral.wrap( tank address )
- end
- periUptd()
- -- Assign terminal glasses bridge adress
- glass = peripheral.wrap("openperipheral_bridge_0")
- -- Number of liquids
- liquids = 2
- -- Possition of text {firstLiquid, secondLiquid, ...}
- Xpos = {5, 5}
- Ypos = {5, 15}
- -- Color of text (in HEX) {firstLiquid, secondLiquid, ...}
- color = {0xff8800, 0x0000ff}
- function tankInfo()
- tankNum = {}
- tanksInfo = {}
- for i = 1, liquids, 1 do
- tanksInfo[i] = {}
- tankNum[i] = 0
- num = 1
- while true do
- if tanks[i][num] == nil then
- break
- end
- num = num+1
- tankNum[i] = tankNum[i]+1
- end
- for num = 1, tankNum[i] do
- tanksInfo[i][num] = tanks[i][num].getTankInfo()
- end
- end
- end
- function clear()
- term.setCursorPos(1, 1)
- term.clear()
- end
- tankInfo()
- function tanksCap()
- capacity = {}
- for i = 1, liquids do
- capacity[i] = 0
- for num = 1, tankNum[i] do
- capacity[i] = capacity[i] + tanksInfo[i][num][1].capacity
- end
- capacity[i] = capacity[i] / 1000
- end
- end
- function tanksAmo()
- amount = {}
- for i = 1, liquids do
- amount[i] = 0
- for num = 1, tankNum[i] do
- if tanksInfo[i][num][1].contents then
- amount[i] = amount[i] + tanksInfo[i][num][1].contents.amount
- end
- end
- amount[i] = amount[i] / 1000
- end
- end
- while true do
- periUptd()
- tankInfo()
- tanksCap()
- tanksAmo()
- clear()
- glass.clear()
- for i = 1, liquids do
- glass.addText(Xpos[i], Ypos[i], amount[i] .. "/" .. capacity[i], color[i])
- end
- glass.sync()
- sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement