Advertisement
Demos_

MinecraftLua_CoreComp

Jan 22nd, 2020
993
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1. -- CompDCoreMon
  2.  
  3. -- DEBUG
  4. DEBUG = true
  5.  
  6. if DEBUG then
  7.     print("[DEBUG] Start of compCore")
  8. end
  9.  
  10. rednetHostname = "compCore"
  11. rednet.open("back")
  12. rednetProtocol = "core"
  13. rednetTimeout = 40
  14. rednet.host(rednetProtocol,rednetHostname)
  15.  
  16. hostnameCMD = "cmdCore"
  17.  
  18. m = peripheral.wrap("bottom")
  19.  
  20. function Draw(v)
  21.     if DEBUG then
  22.         print("[DEBUG] Start of draw v = ",v)
  23.     end
  24.  
  25.     -- v = {totalEnergy,MaxEnergy,tickPerS)
  26.     m.clear()
  27.     m.setBackgroundColor(colors.lightblue)
  28.     m.setCursorPos(1,1)
  29.     m.setTextColor(colors.black)
  30.     m.write("Total charge : ")
  31.     m.setCursorPos(16,1)
  32.     if (v[1] > 0 ) then
  33.         m.setTextColor(colors.green)
  34.     else
  35.         m.setTextColor(colors.red)
  36.     end
  37.     m.write(v[1])
  38.     m.setTextColor(colors.black)
  39.     m.setCursorPos(1,2)
  40.     m.write("[")
  41.     local nbGreen = (v[1] * 100) / v[2]
  42.     m.setTextColor(colors.lime)
  43.     for i=1,nbGreen do
  44.         m.write("I")
  45.     end
  46.     m.setTextColor(colors.black)
  47.     for j=1,(28-nbGreen) do
  48.         m.write('-')
  49.     end
  50.     m.write("]")
  51.     m.setCursorPos(1,4)
  52.     m.write("Rf/tick = ")
  53.     m.setCursorPos(12,4)
  54.     if v[3] > 0 then
  55.         m.setTextColor(colors.green)
  56.     else
  57.         m.setTextColor(colors.red)
  58.     end
  59.     m.write(v[3])
  60. end
  61.  
  62. while true do
  63.     if DEBUG then
  64.         print("[DEBUG] waiting for information")
  65.     end
  66.     id, msg, p, d = rednet.receive(rednetProtocol)
  67.     Draw(v)
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement