Advertisement
kaibochan

ControlCenter.lua

Mar 10th, 2025 (edited)
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. local gui = require("/apis/gui")
  2.  
  3. require("Setup")
  4. local Network = require("Network")
  5.  
  6. function main()
  7.     -- attach modem for listening to status updates
  8.     local modem_name = "modem_1"
  9.     rednet.open(modem_name)
  10.  
  11.     local reactor_dataset = gui.DataSet:new()
  12.  
  13.     local reactor_socket = Network.Socket:new {
  14.         protocol = "Reactor_Status",
  15.         callback = function(self)
  16.             reactor_dataset.data = textutils.unserialise(self.received[1].text)
  17.         end
  18.     }
  19.  
  20.     local displays = attachDisplays()
  21.     local main_display = mainDisplay(displays[1], reactor_dataset)
  22.  
  23.     local function doGUI()    
  24.         while true do
  25.             main_display:render()
  26.             gui.doEvents()
  27.         end
  28.     end
  29.  
  30.     while true do
  31.         parallel.waitForAny(reactor_socket.listen, doGUI)
  32.     end
  33. end
  34.  
  35. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement