Guest User

Slave HUD

a guest
Apr 19th, 2020
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.99 KB | None | 0 0
  1. local me = peripheral.wrap("back")
  2. local g = me.canvas() --canvas/graphics
  3. local modem = peripheral.wrap("right")
  4.  
  5. modem.open(6)
  6.  
  7. show = true
  8.  
  9. stanStat = "Watching for growth..."
  10. ssCol = {255, 0, 0}
  11.  
  12. carlStat = "Chillin' out"
  13. carlCol = {0, 255, 255}
  14.  
  15. waits = 0
  16.  
  17. rf = 1
  18. cap = 1
  19. out = 0
  20.  
  21. function hello()
  22. b1 = g.addRectangle(440, 98, 64, 2)
  23. b2 = g.addRectangle(440, 100, 2, 62)
  24. b3 = g.addRectangle(440, 160, 64, 2)
  25. b4 = g.addRectangle(502, 100, 2, 62)
  26. b1.setColour(0, 0, 0)
  27. b2.setColour(0, 0, 0)
  28. b3.setColour(0, 0, 0)
  29. b4.setColour(0, 0, 0)
  30.  
  31.  
  32. background = g.addRectangle(442, 100, 100, 100)
  33. background.setSize(60, 60)
  34. background.setColour(128, 128, 128)
  35.  
  36. local title = g.addText({ x = 455, y = 101}, "")
  37. title.setScale(0.5)
  38. title.setColour(255, 255, 255)
  39. title.setText("Slave Status")
  40.  
  41. local stan = g.addText({ x = 443, y = 110}, "")
  42. stan.setScale(0.3)
  43. stan.setColour(0, 0, 0)
  44. stan.setText("Stan the man:")
  45.  
  46. stanStatus = g.addText({ x = 465, y = 110}, stanStat)
  47. stanStatus.setScale(0.3)
  48. stanStatus.setColour(ssCol[1], ssCol[2], ssCol[3])
  49. stanStatus.setText(stanStat)
  50.  
  51. pow = setCol((rf / cap) * 100)
  52.  
  53. power = g.addText({x = 445, y = 114}, "")
  54. power.setScale(0.25)
  55. power.setColour(0, 225, 0)
  56. power.setText("Power:")
  57.  
  58. powbar = g.addRectangle(455, 113, 45, 3)
  59. powbar.setColour(0, 0, 0)
  60.  
  61. len = 43 * (rf / cap)
  62.  
  63. len = tonumber(len)
  64.  
  65. if len > 43 then
  66. len = 43
  67. elseif len < 0 then
  68. len = 0
  69. end
  70.  
  71. powb = g.addRectangle(456, 114, 43, 1)
  72. powb.setColour(60, 60, 60)
  73.  
  74. powl = g.addRectangle(456, 114, len, 1)
  75. powl.setColour(pow[1], pow[2], pow[3])
  76.  
  77. carlT = g.addText({x = 443, y = 119}, "")
  78. carlT.setScale(0.3)
  79. carlT.setColour(0, 0, 0)
  80. carlT.setText("Carl's steel:")
  81.  
  82. carlLen = (waits / 100) * 50
  83.  
  84. carlLen = tonumber(carlLen)
  85.  
  86. carlB = g.addRectangle(463, 119.05, carlLen, 2.55)
  87. carlB.setColour(30, 30, 30)
  88.  
  89. carlStatus = g.addText({x = 463, y = 119.25}, "")
  90. carlStatus.setScale(0.28)
  91. carlStatus.setColour(carlCol[1], carlCol[2], carlCol[3])
  92. carlStatus.setText(carlStat)
  93.  
  94. end
  95.  
  96. function setCol(val)
  97. if val < 33 then
  98. return {255, 0, 0}
  99. elseif val < 85 then
  100. return {255, 255, 0}
  101. else
  102. return {0, 255, 0}
  103. end
  104. end
  105.  
  106. function setColRev(val)
  107. if val < 33 then
  108. return {0, 255, 0}
  109. elseif val < 85 then
  110. return {255, 255, 0}
  111. else
  112. return {255, 0, 0}
  113. end
  114. end
  115.  
  116. hello()
  117.  
  118. while true do
  119. local event, key, chan, replyChan, message, dist = os.pullEvent()
  120. if event == "key" then
  121. if key == keys.f then
  122. show = not show
  123. g.clear()
  124. if show then
  125. hello()
  126. end
  127. end
  128. elseif event == "modem_message" then
  129. if replyChan == 69 then
  130. rf = message
  131. elseif replyChan == 70 then
  132. cap = message
  133. elseif replyChan == 71 then
  134. out = message
  135. end
  136. if message == 0 then
  137. stanStat = "Escaping Tower..."
  138. ssCol = {255, 85, 0}
  139. elseif message == 1 then
  140. stanStat = "Watching for growth..."
  141. ssCol = {255, 0, 0}
  142. elseif message == 3 then
  143. stanStat = "Farming... 12.5%"
  144. ssCol = {255, 230, 0}
  145. elseif message == 2 then
  146. stanStat = "Farming... 25%"
  147. ssCol = {255, 230, 0}
  148. elseif message == 4 then
  149. stanStat = "Farming... 37.5%"
  150. ssCol = {255, 230, 0}
  151. elseif message == 5 then
  152. stanStat = "Farming... 50%"
  153. ssCol = {255, 230, 0}
  154. elseif message == 6 then
  155. stanStat = "Farming... 62.5%"
  156. ssCol = {255, 230, 0}
  157. elseif message == 7 then
  158. stanStat = "Farming... 75%"
  159. ssCol = {255, 230, 0}
  160. elseif message == 8 then
  161. stanStat = "Farming... 87.5%"
  162. ssCol = {255, 230, 0}
  163. elseif message == 9 then
  164. stanStat = "Farming... 99%"
  165. ssCol = {255, 230, 0}
  166. elseif message == 10 then
  167. stanStat = "Done, returning..."
  168. ssCol = {0, 255, 0}
  169. elseif message == "grab coal" then
  170. carlStat = "Grabbing a stack of coal..."
  171. carlCol = {50, 50, 50}
  172. elseif message == "grab iron" then
  173. carlStat = "Grabbing a stack of iron..."
  174. carlCol = {255, 255, 255}
  175. elseif message == "use coal" then
  176. carlStat = "Inserting a stack of coal..."
  177. carlCol = {50, 50, 50}
  178. elseif message == "use iron" then
  179. carlStat = "Inserting a stack of iron..."
  180. carlCol = {255, 255, 255}
  181. elseif message == "wait" then
  182. carlStat = "Waiting for enriched..."
  183. carlCol = {235, 235, 0}
  184. waits = replyChan
  185. elseif message == "wait dust" then
  186. carlStat = "Waiting for steel dust..."
  187. carlCol = {235, 235, 0}
  188. waits = replyChan
  189. elseif message == "grab enriched" then
  190. carlStat = "Grabbing enriched iron..."
  191. carlCol = {128, 0, 0}
  192. waits = 0
  193. elseif message == "use enriched" then
  194. carlStat = "Inserting enriched iron..."
  195. carlCol = {128, 0, 0}
  196. elseif message == "grab steel" then
  197. carlStat = "Grabbing steel dust..."
  198. carlCol = {70, 70, 70}
  199. waits = 0
  200. elseif message == "use steel" then
  201. carlStat = "Inserting steel dust..."
  202. carlCol = {70, 70, 70}
  203. elseif message == "done" then
  204. carlStat = "Chillin' out"
  205. carlCol = {0, 255, 255}
  206. end
  207. if show then
  208. g.clear()
  209. hello()
  210. end
  211. end
  212. end
Advertisement
Add Comment
Please, Sign In to add comment