goldfiction

glassesHud

Aug 10th, 2023
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. os.loadAPI("M3C/utils")
  2. os.loadAPI("M3C/kvApi")
  3.  
  4. local glasses = utils.findAndWrap("openperipheral_bridge")
  5. local boxBgColor = 0xFFFFFF
  6. local boxTextColor = 0xF5F5F5
  7. local boxStartXCoord = 0
  8. local boxStartYCoord = 20
  9.  
  10. function drawBox(height)
  11. glasses.addBox(boxStartXCoord, boxStartYCoord, 170, height, boxBgColor, .2)
  12. end
  13.  
  14. function display(text)
  15. glasses.clear()
  16. local yPos = boxStartYCoord
  17. for index,line in utils.orderTable(text) do
  18. glasses.addText(boxStartXCoord + 5, yPos, index .. ": " .. line, boxTextColor)
  19. yPos = yPos + 10
  20. end
  21.  
  22. drawBox(yPos - boxStartYCoord)
  23. glasses.sync()
  24. end
  25.  
  26. kvApi.initializeWirelessModems()
  27.  
  28. while true do
  29. local powerStatus = kvApi.deserializeKvResponse(kvApi.clientGet("powerStatus"))
  30. sleep(5)
  31. local meStatus = kvApi.deserializeKvResponse(kvApi.clientGet("meStatus"))
  32. sleep(5)
  33. local reactor = kvApi.deserializeKvResponse(kvApi.clientGet("reactorStatus"))
  34.  
  35. local displayText={}
  36. if powerStatus ~= "No key found!" then
  37. displayText["Power"] = utils.formatInt(powerStatus.Available) .. "%" .. " @ " .. powerStatus.Updated
  38. end
  39. if meStatus ~= "No key found!" then
  40. displayText["ME Slots"] = utils.formatInt(meStatus.usedSlots) .. "/" .. utils.formatInt(meStatus.totalSlots) .. " @ " .. meStatus.Updated
  41. displayText["ME Bytes"] = utils.convertMEBytes(meStatus.usedBytes) .. "/" .. utils.convertMEBytes(meStatus.totalBytes) .. " @ " .. meStatus.Updated
  42. end
  43. if reactor ~= "No key found!" then
  44. displayText["Blutonium"] = utils.formatInt(reactor["Blutonium Ingot"]) .. " @ " .. reactor["Updated"]
  45. displayText["Yellorium"] = utils.formatInt(reactor["Yellorium Ingot"]) .. " @ " .. reactor["Updated"]
  46. end
  47.  
  48. display(displayText)
  49. sleep(25)
  50. end
  51.  
Add Comment
Please, Sign In to add comment