Advertisement
Guest User

reactor

a guest
Jan 8th, 2014
9,657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.48 KB | None | 0 0
  1. --[[
  2.     Program name: EZ-NUKE reactor control system
  3.     Version: v0002 Pre-alpha
  4.     Programmer: ScatmanJohn
  5.     Last update: 8.1.2014
  6.     Pastebin: http://pastebin.com/sUiYsgmp
  7.     Description:
  8.     This program controls a Big Reactors nuclear reactor
  9.     in Minecraft with a Computercraft computer, using Computercraft's
  10.     own wired modem connected to the reactors computer control port.
  11.     Resources:
  12.     Reactor control:
  13.         http://pastebin.com/HjUVNDau
  14.     FC API:
  15.         http://pastebin.com/A9hcbZWe
  16.     Monitor size is X: 29, Y: 12 with a 3x2 size
  17. ]]--
  18.  
  19. print("Initializing program...");
  20.  
  21. function wrapThis(thing)
  22.         local wrapped, i = nil, 0
  23.         while wrapped == nil and i <= 100 do
  24.                 wrapped = peripheral.wrap(thing.."_"..i)
  25.                 i = i + 1
  26.         end
  27.  
  28.         if wrapped == nil then
  29.                 side = getDeviceSide(thing)
  30.                 if side ~= nil then
  31.                         return peripheral.wrap(side)
  32.                 else
  33.                         return nil
  34.                 end
  35.         else
  36.                 return wrapped
  37.         end
  38. end
  39.  
  40. -- Then initialize the monitor
  41. local monitor = wrapThis("monitor")
  42. if monitor == nil then
  43.     print("Can't find monitor.")
  44. end
  45.  
  46. local inittext = "Monitor initialized"
  47. local monitorx, monitory = monitor.getSize()
  48. local textx, texty = monitorx/4, monitory/2
  49.  
  50. monitor.clear()
  51. monitor.setCursorPos(textx, texty)
  52. monitor.write(inittext)
  53. monitor.setCursorPos(1,1)
  54. monitor.write("1")
  55. monitor.setCursorPos(1,monitory)
  56. monitor.write("3")
  57. monitor.setCursorPos(monitorx,1)
  58. monitor.write("2")
  59. monitor.setCursorPos(monitorx,monitory)
  60. monitor.write("4")
  61. print("X size: "..monitorx.." characters.")
  62. print("Y size: "..monitory.." characters.")
  63.  
  64. -- Let's connect to the reactor peripheral
  65. local reactor = wrapThis("BigReactors-Reactor")
  66. if reactor == nil then
  67.     print("Can't find reactor.")
  68. end
  69.  
  70. local temp = reactor.getTemperature()
  71. print("Temperature: "..temp)
  72.  
  73. print("Everything went better than expected.")
  74.  
  75. -- Begin loop to fetch reactor data and display it on the monitor
  76. --[[
  77.  
  78. while 1 do
  79.     -- Retrieve reactor data
  80.    
  81.     -- Prepare the printable elements
  82.    
  83.     -- Print elements in their spots on the monitor
  84. end
  85.  
  86. ]]--
  87.  
  88. --[[ OLD CODE USED FOR TESTING
  89.  
  90. print("Program loaded. Scanning for reactor...");
  91. local reactor
  92. reactor = peripheral.wrap("back")
  93. isactive = reactor.getActive();
  94. if isactive == true
  95.     print("Reactor active.");
  96.     monitor.print("All's well!");
  97. else
  98.     print("Reactor inactive.");
  99. end
  100.  
  101. ]]--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement