Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --SteamPunk_Devil's Tank Monitor!
- print("SteamPunk_Devil's Tank Monitor V0.01")
- os.unloadAPI("API/steAmPI")
- os.loadAPI("API/steAmPI")
- while true do
- sleep(.1)
- local PeriList = peripheral.getNames()
- local TankList = {}
- local OtherPeriList = {}
- local MonList = {}
- --local o = 1
- --local u = 1
- --local m = 1
- for i = 1, #PeriList do
- if string.match(PeriList[i],"rcirontankvalvetile") then
- TankList[#TankList + 1] = PeriList[i]
- --u = u + 1
- elseif string.match(PeriList[i],"monitor") then
- MonList[#MonList + 1] = PeriList[i]
- --m = m + 1
- else
- OtherPeriList[#OtherPeriList + 1] = PeriList[i]
- --print(textutils.serialize(OtherPeriList))
- end
- end
- local Tank1 = peripheral.wrap(TankList[1])
- local Tank2 = peripheral.wrap(TankList[2])
- local Tank3 = peripheral.wrap(TankList[3])
- local Tank4 = peripheral.wrap(TankList[4])
- local Mon = peripheral.wrap(MonList[1])
- local X1Pos = 2
- local X2Pos =18
- local Y1Pos = 2
- local Y1BarPos = 3
- local Y2Pos = 5
- local Y2BarPos = 6
- DoubleArray1 = Tank1.getTankInfo("unknown")
- SingleArray1 = DoubleArray1[1]
- DoubleArray2 = Tank2.getTankInfo("unknown")
- SingleArray2 = DoubleArray2[1]
- DoubleArray3 = Tank3.getTankInfo("unknown")
- SingleArray3 = DoubleArray3[1]
- DoubleArray4 = Tank4.getTankInfo("unknown")
- SingleArray4 = DoubleArray4[1]
- tank1 = SingleArray1
- tank1["XPos"] = X1Pos
- tank1["YPos"] = Y1Pos
- tank1["YBarPos"] = Y1BarPos
- tank2 = SingleArray2
- tank2["XPos"] = X2Pos
- tank2["YPos"] = Y1Pos
- tank2["YBarPos"] = Y1BarPos
- tank3 = SingleArray3
- tank3["XPos"] = X1Pos
- tank3["YPos"] = Y2Pos
- tank3["YBarPos"] = Y2BarPos
- tank4 = SingleArray4
- tank4["XPos"] = X2Pos
- tank4["YPos"] = Y2Pos
- tank4["YBarPos"] = Y2BarPos
- Mon.clear()
- if #TankList >= 1 then
- steAmPI.FluPrinter(tank1)
- else
- Mon.setCursorPos(X1Pos, Y1Pos)
- Mon.setTextColor(128)
- Mon.write(" Empty ")
- Mon.setCursorPos(X1Pos, Y1BarPos)
- Mon.setBackgroundColor(128)
- Mon.write(" ")
- Mon.setBackgroundColor(32768)
- end
- if #TankList >= 2 then
- steAmPI.FluPrinter(tank2)
- else
- Mon.setCursorPos(X2Pos, Y1Pos)
- Mon.setTextColor(128)
- Mon.write(" Empty ")
- Mon.setCursorPos(X2Pos, Y1BarPos)
- Mon.setBackgroundColor(128)
- Mon.write(" ")
- Mon.setBackgroundColor(32768)
- end
- if #TankList >= 3 then
- steAmPI.FluPrinter(tank3)
- else
- Mon.setCursorPos(X1Pos, Y2Pos)
- Mon.setTextColor(128)
- Mon.write(" Empty ")
- Mon.setCursorPos(X1Pos, Y2BarPos)
- Mon.setBackgroundColor(128)
- Mon.write(" ")
- Mon.setBackgroundColor(32768)
- end
- if #TankList >= 4 then
- steAmPI.FluPrinter(tank4)
- else
- Mon.setCursorPos(X2Pos, Y2Pos)
- Mon.setTextColor(128)
- Mon.write(" Empty ")
- Mon.setCursorPos(X2Pos, Y2BarPos)
- Mon.setBackgroundColor(128)
- Mon.write(" ")
- Mon.setBackgroundColor(32768)
- end
- os.startTimer(0.2) --start the timer
- local MonTouch = {os.pullEvent()}
- if MonTouch[1] == "monitor_touch" then
- if MonTouch[3] >= X1Pos and MonTouch[3] <= X1Pos + 10 and MonTouch[4] >= Y1Pos and MonTouch[4] <= Y1Pos + 1 then
- OnPushData(tank1, Mon)
- elseif MonTouch[3] >= X2Pos and MonTouch[3] <= X2Pos + 10 and MonTouch[4] >= Y1Pos and MonTouch[4] <= Y1Pos + 1 then
- OnPushData(tank2, Mon)
- elseif MonTouch[3] >= X1Pos and MonTouch[3] <= X1Pos + 10 and MonTouch[4] >= Y2Pos and MonTouch[4] <= Y2Pos + 1 then
- OnPushData(tank3, Mon)
- elseif MonTouch[3] >= X2Pos and MonTouch[3] <= X2Pos + 10 and MonTouch[4] >= Y2Pos and MonTouch[4] <= Y2Pos + 1 then
- OnPushData(tank4, Mon)
- else
- end
- else
- --skip
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement