Advertisement
cowslaw

Base Monitoring System v3

Apr 4th, 2014
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.52 KB | None | 0 0
  1. -- Base Monitoring System By: ZakyyyHD (VintageGaming)
  2. -- Personal Use
  3.  
  4. -- User Options [For Users! Change options based on preference and locations of peripherals]
  5. local EUstorage = true
  6. local reactor = false
  7. local EUcapacity = 40000
  8. local EUstorageType = "BatBox"
  9. local userBridgeLoc = "left"
  10. local userNetLoc = "right"
  11. local userMonLoc = "top"
  12. local userReactorLoc = "BigReactors-Reactor_0"
  13. local userNetStorageType = "batbox_0"
  14.  
  15. -- Variables
  16. local bridge = peripheral.wrap(userBridgeLoc)
  17. local monitor = peripheral.wrap(userMonLoc)
  18. local net = peripheral.wrap(userNetLoc)
  19. local offset = 0
  20. local width = 50
  21. local yAxis = 4
  22. local storageUnits = {
  23.    {
  24.          ["id"] = userNetStorageType,
  25.          ["name"] = EUstorageType,
  26.    }
  27. }
  28.  
  29. -- Main Script [DO NOT EDIT!]
  30. bridge.addBox(2, 2, 54, 19, 0xFFFFFF, 0.3)
  31. for key, storageUnit in pairs(storageUnits) do
  32.   pxOffset = offset * 20
  33.   storageUnit["label"] = bridge.addText(4, 4 + pxOffset, storageUnit["name"], 0x000000)
  34.   storageUnit["bar"] = bridge.addBox(4, 14 + pxOffset, 0, 5, 0xFF0000, 0.9)
  35. --  storageUnit["bar"].setZIndex(2)
  36.   storageUnit["bg"] = bridge.addBox(4, 14 + pxOffset, width, 5, 0x000000, 0.5)
  37.   offset = offset + 1
  38. end
  39.  
  40. while true do
  41.  -- Monitor
  42.  monitor.clear()
  43.  monitor.setCursorPos(2,1)
  44.  monitor.write("Home Monitoring System v3.0")
  45.  monitor.setCursorPos(1,3)
  46.  EUs = net.callRemote(userNetStorageType, "getEUStored")
  47.  if EUs > EUcapacity then
  48.   EUs = EUcapacity
  49.  end
  50.  if EUs <= EUcapacity then
  51.  end
  52.  if EUstorage == true then
  53.   monitor.setCursorPos(1, yAxis)
  54.   monitor.write(EUstorageType.. ": ".. EUs .. " / ".. EUcapacity .. " EU.")
  55.  else
  56.  end
  57.  if reactor == true then
  58.   monitor.setCursorPos(1, yAxis + 1)
  59.   monitor.write("Reactor Temp: ".. net.callRemote("BigReactors-Reactor_3", "getTemperature") .. " Degrees.")
  60.   monitor.setCursorPos(1, yAxis + 2)
  61.   monitor.write("Reactor RF: ".. net.callRemote("BigReactors-Reactor_3", "getEnergyStored") .. " RF.")
  62.  else
  63.  end
  64.  
  65.   -- Terminal Glasses
  66.   for i=#storageUnits,1,-1 do
  67.         storageUnit = storageUnits[i]
  68.         if net.isPresentRemote(storageUnit["id"]) then
  69.           capacity = net.callRemote(storageUnit["id"], "getEUCapacity")
  70.           amount = net.callRemote(storageUnit["id"], "getEUStored")
  71.           storageUnit["bar"].setWidth(width / capacity * amount)
  72.         else
  73.          -- storageUnit["bar"].delete()
  74.          -- storageUnit["bg"].delete()
  75.          -- storageUnit["label"].delete()
  76.           table.remove(storageUnits, i)
  77.         end
  78.   end
  79.   sleep(0.5)
  80. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement