Advertisement
Muhi98

Fission Reactor

Aug 16th, 2022 (edited)
912
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | Gaming | 0 0
  1. local comp = require("component")
  2. local event = require("event")
  3. local term = require("term")
  4. local m = comp.modem
  5.  
  6.  
  7.  
  8. function GetReactorInfo(react)
  9.     for k in pairs(react) do print(k) end
  10.     local currHeat = react.getHeatLevel()
  11.     local maxHeat = react.getMaxHeatLevel()
  12.     local isOn = react.isProcessing()
  13.    
  14.     return currHeat, maxHeat, isOn
  15. end
  16.  
  17.  
  18.  
  19.  
  20.  
  21. print("Welcome to FRC (Fission Reactor Control) v1.0")
  22. print("\nChoose (R)eceiver or (S)ender: ")
  23. local userInput = term.read()
  24.  
  25.  
  26. --MAIN LOOP RECEIVER
  27. if(userInput.find(userInput, "R")) then
  28.     term.clear()
  29.     print("Receiver")
  30.     print("\nWaiting for initial Message...")
  31.     local _, _, _, _, _, react1, react2 = event.pull("modem_message")
  32.     print("Got message!")
  33.     print("\n".. react1[1] .. " ?")
  34.    
  35.     --MAIN LOOP RECEIVER
  36.     while(true) do
  37.         print("Waiting for answer...")
  38.         local _, _, _, _, _, react1, react2 = event.pull("modem_message")
  39.         term.clear()
  40.     end
  41. end
  42.  
  43. --SENDER
  44.  
  45. if(userInput.find(userInput, "S")) then
  46.     reactors = {}--get all reactors
  47.     term.clear()
  48.     print("Sender")
  49.  
  50.     --MAIN LOOP SENDER
  51.     while(true) do
  52.        
  53.  
  54.         local currHeat1, maxHeat1, isOn1 = GetReactorInfo(reactors[1])
  55.         local currHeat2, maxHeat2, isOn2 = GetReactorInfo(reactors[2])
  56.  
  57.         reac1 = {currHeat1, maxHeat1, isOn1}
  58.         reac2 = {currHeat2, maxHeat2, isOn2}
  59.  
  60.         m.broadcast(1337, reac1, reac2)
  61.         os.sleep(3)
  62.     end
  63. end
  64.  
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement