NolanSyKinsley

Untitled

Apr 3rd, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.11 KB | None | 0 0
  1. ae = peripheral.wrap("left")
  2. p = peripheral.wrap("right")
  3. e = peripheral.wrap("top")
  4. aecolorfront = 0x9900CC
  5. aecolorback = 0xFFFFFF
  6. powercolorfront = 0xCC0000
  7. powercolorback = 0xFFFFFF
  8. p.clear()
  9.  
  10. variables = {
  11. ["width"] = 95,
  12. ["height"] = 100,
  13. ["lineTransparency"] = 1,
  14. ["innerTransparency"] = 0.65,
  15. ["lineColour"] = 0x000000,
  16. ["middleColour"] = 0x00000
  17. }
  18. groups = {
  19. ["left_transparency"] = {
  20. [1] = {x=2, y=11, width=1, height="height+00",colour="middleColour+0",transparency="innerTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  21. [2] = {x=3, y=08, width=1, height="height+06",colour="middleColour+0",transparency="innerTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  22. [3] = {x=4, y=06, width=1, height="height+10",colour="middleColour+0",transparency="innerTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  23. [4] = {x=5, y=05, width=1, height="height+12",colour="middleColour+0",transparency="innerTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  24. [5] = {x=6, y=04, width=2, height="height+14",colour="middleColour+0",transparency="innerTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  25. [6] = {x=8, y=03, width=3, height="height+16",colour="middleColour+0",transparency="innerTransparency+0",obj=p.addBox(0,0,0,0,0,0)}
  26. },
  27. ["middle_transparency"] = {
  28. [1] = {x=11,y=2,width="width+0",height="height+18",colour="middleColour+0",transparency="innerTransparency+0",obj=p.addBox(0,0,0,0,0,0)}
  29. },
  30. ["right_transparency"] = {
  31. [1] = {x="width+11", y=03, width=3, height="height+16",colour="middleColour+0",transparency="innerTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  32. [2] = {x="width+14", y=04, width=2, height="height+14",colour="middleColour+0",transparency="innerTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  33. [3] = {x="width+16", y=05, width=1, height="height+12",colour="middleColour+0",transparency="innerTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  34. [4] = {x="width+17", y=06, width=1, height="height+10",colour="middleColour+0",transparency="innerTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  35. [5] = {x="width+18", y=08, width=1, height="height+06",colour="middleColour+0",transparency="innerTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  36. [6] = {x="width+19", y=11, width=1, height="height+00",colour="middleColour+0",transparency="innerTransparency+0",obj=p.addBox(0,0,0,0,0,0)}
  37. },
  38. ["top_left"] = {
  39. [1] = {x=8,y=2,width=3,height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  40. [2] = {x=6,y=3,width=2,height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  41. [3] = {x=4,y=5,width=1,height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  42. [4] = {x=5,y=4,width=1,height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  43. [5] = {x=3,y=6,width=1,height=2,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  44. [6] = {x=2,y=8,width=1,height=3,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)}
  45. },
  46. ["top"] = {
  47. [1] = {x=11,y=1,width="width+0",height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)}
  48. },
  49. ["top_right"] = {
  50. [1] = {x="width+11",y=2,width=3,height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  51. [2] = {x="width+14",y=3,width=2,height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  52. [3] = {x="width+16",y=4,width=1,height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  53. [4] = {x="width+17",y=5,width=1,height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  54. [5] = {x="width+18",y=6,width=1,height=2,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  55. [6] = {x="width+19",y=8,width=1,height=3,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)}
  56. },
  57. ["left"] = {
  58. [1] = {x=1,y=11,width=1,height="height+0",colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)}
  59. },
  60. ["right"] = {
  61. [1] = {x="width+20",y=11,width=1,height="height+0",colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)}
  62. },
  63. ["bottom_left"] = {
  64. [1] = {x=2,y="height+11",width=1,height=3,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  65. [2] = {x=3,y="height+14",width=1,height=2,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  66. [3] = {x=4,y="height+16",width=1,height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  67. [4] = {x=5,y="height+17",width=1,height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  68. [5] = {x=6,y="height+18",width=2,height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  69. [6] = {x=8,y="height+19",width=3,height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)}
  70. },
  71. ["bottom"] = {
  72. [1] = {x=11,y="height+20",width="width+0",height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)}
  73. },
  74. ["bottom_right"] = {
  75. [1] = {x="width+19",y="height+11",width=1,height=3,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  76. [2] = {x="width+18",y="height+14",width=1,height=2,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  77. [3] = {x="width+17",y="height+16",width=1,height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  78. [4] = {x="width+16",y="height+17",width=1,height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  79. [5] = {x="width+14",y="height+18",width=2,height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)},
  80. [6] = {x="width+11",y="height+19",width=3,height=1,colour="lineColour+0",transparency="lineTransparency+0",obj=p.addBox(0,0,0,0,0,0)}
  81. }
  82. }
  83. function renderGroup(groupName)
  84. group = groups[groupName]
  85. for key, object in pairs(group) do
  86. if type(object["x"]) == "number" then
  87. object["obj"].setX(object["x"])
  88. elseif type(object["x"]) == "string" then
  89. t = {}
  90. for k, v in string.gmatch(object["x"], "(%w+)+(%w+)") do
  91. t[1] = k
  92. t[2] = v
  93. end
  94. object["obj"].setX(tonumber(variables[t[1]])+tonumber(t[2]))
  95. end
  96. if type(object["y"]) == "number" then
  97. object["obj"].setY(object["y"])
  98. elseif type(object["y"]) == "string" then
  99. t = {}
  100. for k, v in string.gmatch(object["y"], "(%w+)+(%w+)") do
  101. t[1] = k
  102. t[2] = v
  103. end
  104. object["obj"].setY(tonumber(variables[t[1]])+tonumber(t[2]))
  105. end
  106. if type(object["width"]) == "number" then
  107. object["obj"].setWidth(object["width"])
  108. elseif type(object["width"]) == "string" then
  109. t = {}
  110. for k, v in string.gmatch(object["width"], "(%w+)+(%w+)") do
  111. t[1] = k
  112. t[2] = v
  113. end
  114. object["obj"].setWidth(tonumber(variables[t[1]])+tonumber(t[2]))
  115. end
  116. if type(object["height"]) == "number" then
  117. object["obj"].setHeight(object["height"])
  118. elseif type(object["height"]) == "string" then
  119. t = {}
  120. for k, v in string.gmatch(object["height"], "(%w+)+(%w+)") do
  121. t[1] = k
  122. t[2] = v
  123. end
  124. object["obj"].setHeight(tonumber(variables[t[1]])+tonumber(t[2]))
  125. end
  126. if type(object["colour"]) == "number" then
  127. object["obj"].setColor(object["colour"])
  128. elseif type(object["colour"]) == "string" then
  129. t = {}
  130. for k, v in string.gmatch(object["colour"], "(%w+)+(%w+)") do
  131. t[1] = k
  132. t[2] = v
  133. end
  134. object["obj"].setColor(tonumber(variables[t[1]])+tonumber(t[2]))
  135. end
  136. if type(object["transparency"]) == "number" then
  137. object["obj"].setOpacity(object["transparency"])
  138. elseif type(object["transparency"]) == "string" then
  139. t = {}
  140. for k, v in string.gmatch(object["transparency"], "(%w+)+(%w+)") do
  141. t[1] = k
  142. t[2] = v
  143. end
  144. object["obj"].setOpacity(tonumber(variables[t[1]])+tonumber(t[2]))
  145. end
  146. end
  147. end
  148. function redraw()
  149. for key,value in pairs(groups) do
  150. renderGroup(key)
  151. end
  152. end
  153. redraw()
  154.  
  155. function DrawHUD()
  156.  
  157. diamondOre = ae.countOfItemType(56, 0)
  158. diamonds = ae.countOfItemType(264, 0)
  159. ironOre = ae.countOfItemType(15, 0)
  160. yelloriteOre = ae.countOfItemType(3750, 0)
  161. coalOre = ae.countOfItemType(16, 0)
  162. coal = ae.countOfItemType(263, 0)
  163. torches = ae.countOfItemType(50, 0)
  164.  
  165. diamondOreText = p.addText(8,30,"Diamond Ore = "..diamondOre, 0xFFFFFF)
  166. diamondsText = p.addText(8,40,"Diamonds = "..diamonds, 0xFFFFFF)
  167. ironOreText = p.addText(8,50,"Iron Ore = "..ironOre, 0xFFFFFF)
  168. yelloriteOreText = p.addText(8,60,"Yellorite Ore = "..yelloriteOre, 0xFFFFFF)
  169. coalOreText = p.addText(8,70,"Coal Ore = "..coalOre, 0xFFFFFF)
  170. coalText = p.addText(8,80,"Coal = "..coal, 0xFFFFFF)
  171. torchesText= p.addText(8,90,"Torches = "..torches, 0xFFFFFF)
  172.  
  173. aeTotalSpace = ae.getTotalBytes()
  174. ab = ae.getFreeBytes()
  175. ab = ab / aeTotalSpace*100
  176. ab = 100 - ab
  177. aeback = p.addBox(8,10,100.00345,5,aecolorback,0.5)
  178. aefore = p.addBox(8,10,ab,5,aecolorfront,1)
  179.  
  180. pwTotalEnergy = e.getEnergyStored("north")
  181. pw = e.getMaxEnergyStored("north")
  182. pw = pw / pwTotalEnergy
  183. pw = 100 / pw
  184. eback = p.addBox(8,18,100.00345,5,powercolorback,0.5)
  185. efore = p.addBox(8,18,pw,5,powercolorfront,1)
  186. end
  187. DrawHUD()
  188.  
  189. function ReDrawHUD()
  190. sleep(0)
  191.  
  192. diamondOre = ae.countOfItemType(56, 0)
  193. diamonds = ae.countOfItemType(264, 0)
  194. ironOre = ae.countOfItemType(15, 0)
  195. yelloriteOre = ae.countOfItemType(3750, 0)
  196. coalOre = ae.countOfItemType(16, 0)
  197. coal = ae.countOfItemType(263, 0)
  198. torches = ae.countOfItemType(50, 0)
  199.  
  200. diamondOreText.setText("Diamond Ore = "..diamondOre)
  201. diamondsText.setText("Diamonds = "..diamonds)
  202. ironOreText.setText("Iron Ore = "..ironOre)
  203. yelloriteOreText.setText("Yellorite Ore = "..yelloriteOre)
  204. coalOreText.setText("Coal Ore = "..coalOre)
  205. coalText.setText("Coal = "..coal)
  206. torchesText.setText("Torches = "..torches)
  207.  
  208. aeTotalSpace = ae.getTotalBytes()
  209. ab = ae.getFreeBytes()
  210. ab = ab / aeTotalSpace*100
  211. ab = 100 - ab
  212. aefore.setWidth(ab)
  213.  
  214. pwTotalEnergy = e.getEnergyStored("north")
  215. pw = e.getMaxEnergyStored("north")
  216. pw = pw / pwTotalEnergy
  217. pw = 100 / pw
  218. efore.setWidth(pw)
  219. sleep(5)
  220. end
  221.  
  222. function reboot()
  223. os.reboot()
  224. end
  225.  
  226. function Commands()
  227.  
  228. local evt,command = os.pullEvent("chat_command")
  229. local redStoneBottom = false
  230.  
  231. if command == "redrawhud" then
  232. ReDrawHUD()
  233. end
  234.  
  235. if command == "start" then
  236. redStoneBottom = true
  237. end
  238.  
  239. if command == "stop" then
  240. redstoneBottom = false
  241. end
  242.  
  243. if command == "reboot" then
  244. reboot()
  245. end
  246.  
  247. if command == "clear" then
  248. p.clear()
  249. end
  250.  
  251. if redStoneBottom == true then
  252. redstone.setOutput("bottom", true)
  253. elseif redStoneBottom == false then
  254. redstone.setOutput("bottom", false)
  255. end
  256. end
  257. while true do
  258. parallel.waitForAny(Commands, ReDrawHUD)
  259. end
Add Comment
Please, Sign In to add comment