FailedFace

TermGlassesMultiv4

Mar 22nd, 2014
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.90 KB | None | 0 0
  1. --Variables
  2. -- peripherals
  3. local bridge = peripheral.wrap("left")
  4. -- modem names
  5. local mfe = "mfe_0"
  6. local meSys = "appeng_me_tilecontroller_0"
  7. local rcTanks = "rc_irontankvavletile_1", "rc_irontankvalvetile_2", "rc_irontankvalvetile_3", "rc_irontankvalvetile_4"
  8. -- AE
  9. local itemID = 3 -- initialize to dirt
  10. local itemName = "Dirt"
  11. -- IC2
  12.  
  13. -- RC
  14. -- colors
  15. local red = 0xFF0000
  16. local yellow = 0xFFFF00
  17. local black = 0x000000
  18. -- update delay(lower the more updates)
  19. local delay = 1 --1 second
  20. -- Functions
  21.  
  22. function IC2Box()
  23.   ic2Box = bridge.addBox(5, 5, 100, 50, black, 0.5)
  24.   ic2TextHeader = bridge.addText(48, 5, "IC2", red)
  25.   ic2Text1 = bridge.addText(5, 15, "", yellow)
  26.   ic2Text2 = bridge.addText(5, 25, "", yellow)
  27. end
  28.  
  29. function IC2Clear()
  30.   ic2Text1.setText("")
  31.   ic2Text2.setText("")
  32.   ic2TextHeader.setText("")
  33.   ic2Box.setOpacity(0)
  34. end
  35.  
  36. function AEBox()
  37.   aeBox = bridge.addBox(5, 65, 100, 50, black, 0.5)
  38.   aeTextHeader = bridge.addText(49, 65, "AE", red)
  39.   aeText1 = bridge.addText(5, 75, "", yellow)
  40.   aeText2 = bridge.addText(5, 85, "", yellow)
  41.   aeText3 = bridge.addText(5, 95, "", yellow)
  42. end
  43.  
  44. function AEClear()
  45.   aeText1.setText("")
  46.   aeText2.setText("")
  47.   aeText3.setText("")
  48.   aeTextHeader.setText("")
  49.   aeBox.setOpacity(0)
  50. end
  51.  
  52. function calcIC2()
  53.   local currentEU = peripheral.call(mfe, "getEUStored")
  54.   local maxEU = peripheral.call(mfe, "getEUCapacity")
  55.   ic2Text1.setText(currentEU.." EU")
  56.   ic2Text2.setText(maxEU.." EU Max")
  57. end
  58.  
  59. function calcAE()
  60.   local storedItemCount = peripheral.call(meSys, "getStoredItemCount")
  61.   local itemCount = peripheral.call(meSys, "countOfItemType",itemID,"0")
  62.   local bytesFree = peripheral.call(meSys, "getFreeBytes")
  63.   aeText1.setText(storedItemCount.." Items")
  64.   aeText2.setText(itemCount.." "..itemName)
  65.   aeText3.setText(bytesFree.." bytes free")
  66. end
  67.  
  68. -- initialize
  69. local ic2HUD = true
  70. local aeHUD = true
  71. bridge.clear()
  72. IC2Box()
  73. AEBox()
  74. -- loop
  75. while true do
  76.   local myTimer = os.startTimer(delay)
  77.   local event, message = os.pullEvent()
  78.   local firstParam = string.match(message, '[a-z]+')
  79.   local secondParam = string.match(message, '%d+')
  80.   local thirdParam = string.match(message, '[a-zA-Z]-$')
  81.  
  82.   if ic2HUD == true then calcIC2() end
  83.   if aeHUD == true then calcAE() end
  84.  
  85.   if event == "chat_command" then
  86.     if message == "ic2off" then
  87.       IC2Clear()
  88.       ic2HUD = false
  89.  
  90.     elseif message == "aeoff" then
  91.       AEClear()
  92.       aeHUD = false
  93.  
  94.     elseif message == "ic2on" then
  95.       calcIC2()
  96.       ic2TextHeader.setText("IC2")
  97.       ic2Box.setOpacity(0.5)
  98.       ic2HUD = true
  99.  
  100.     elseif message == "aeon" then
  101.       calcAE()
  102.       aeTextHeader.setText("AE")
  103.       aeBox.setOpacity(0.5)
  104.       aeHUD = true
  105.      
  106.     elseif firstParam == "aeitemcount" then
  107.       itemID = secondParam
  108.       itemName = thirdParam
  109.       calcAE()
  110.     else
  111.       -- Do Nothing
  112.     end
  113.   end
  114. end
Advertisement
Add Comment
Please, Sign In to add comment