View difference between Paste ID: Ef3kz8Je and 6LC0uk1S
SHOW: | | - or go back to the newest paste.
1
--Variables
2
-- peripherals
3
local bridge = peripheral.wrap("left")
4
-- names
5
local mfsu = "mfsu_0"
6
local meChest = "me_chest_0"
7
-- colors
8
local red = 0xFF0000
9
local yellow = 0xFFFF00
10
local black = 0x000000
11
-- update delay(lower the more updates)
12
local delay = 1 --1 second
13
-- Functions
14
15
function IC2Box()
16
  ic2Box = bridge.addBox(5, 5, 100, 50, black, 0.5)
17
  ic2TextHeader = bridge.addText(48, 5, "IC2", red)
18
  ic2Text1 = bridge.addText(5, 15, "", yellow)
19
  ic2Text2 = bridge.addText(5, 25, "", yellow)
20
end
21
22
function IC2Clear()
23
  ic2Text1.setText("")
24
  ic2Text2.setText("")
25
  ic2TextHeader.setText("")
26
  ic2Box.setOpacity(0)
27
end
28
29
function AEBox()
30
  aeBox = bridge.addBox(5, 65, 100, 50, black, 0.5)
31
  aeTextHeader = bridge.addText(49, 65, "AE", red)
32
  aeText1 = bridge.addText(5, 75, "", yellow)
33
  aeText2 = bridge.addText(5, 85, "", yellow)
34
  aeText3 = bridge.addText(5, 95, "", yellow)
35
end
36
37
function AEClear()
38
  aeText1.setText("")
39
  aeText2.setText("")
40
  aeText3.setText("")
41
  aeTextHeader.setText("")
42
  aeBox.setOpacity(0)
43
end
44
45
function calcIC2()
46
  local currentEU = peripheral.call(mfsu, "getEUStored")
47
  local maxEU = peripheral.call(mfsu, "getEUCapacity")
48
  ic2Text1.setText(currentEU.." EU")
49
  ic2Text2.setText(maxEU.." EU Max")
50
end
51
52
function calcAE()
53
  local storedItemCount = peripheral.call(meChest, "getStoredItemCount")
54
  local dirtCount = peripheral.call(meChest, "countOfItemType","3","0")
55
  local bytesFree = peripheral.call(meChest, "getFreeBytes")
56
  aeText1.setText(storedItemCount.." Items")
57
  aeText2.setText(dirtCount.." Dirt")
58
  aeText3.setText(bytesFree.." bytes free")
59
end
60
61
-- initialize
62
local ic2HUD = true
63
local aeHUD = true
64
bridge.clear()
65
IC2Box()
66
AEBox()
67
-- loop
68
while true do
69
  local myTimer = os.startTimer(delay)
70
  local event, message = os.pullEvent()
71
  
72
  if ic2HUD == true then calcIC2() end
73
  if aeHUD == true then calcAE() end
74
  
75
  if event == "chat_command" then
76
    if message == "ic2off" then
77
      IC2Clear()
78
      ic2HUD = false
79
80-
    if message == "aeoff" then
80+
    elseif message == "aeoff" then
81-
      aeText1.setText("")
81+
      AEClear()
82-
      aeText2.setText("")
82+
83-
      aeText3.setText("")
83+
84-
      aeTextHeader.setText("")
84+
    elseif message == "ic2on" then
85-
      aeBox.setOpacity(0)
85+
86
      ic2TextHeader.setText("IC2")
87
      ic2Box.setOpacity(0.5)
88-
    if message == "ic2on" then
88+
89
90
    elseif message == "aeon" then
91
      calcAE()
92
      aeTextHeader.setText("AE")
93
      aeBox.setOpacity(0.5)
94-
    if message == "aeon" then
94+
95
96
    else
97
      -- Do Nothing
98
    end
99
  end
100
end