Guest User

startup

a guest
May 1st, 2013
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.62 KB | None | 0 0
  1. --Beginning Declarations
  2.  
  3. monitor =  peripheral.wrap("top")
  4. monitor.clear()
  5. nir = peripheral.wrap("left")
  6. local nuke = paintutils.loadImage("nuke")
  7. os.loadAPI("disk/buttons")
  8. addButton("NuclearReactorToggle",no,reactorToggle,colors.yellow,colors.yellow,colors.black,1,1,25,1)
  9. function reactorToggle()
  10.   rednet.open("bottom")
  11.   if reactorNumb == 1 then
  12.     rednet.send(255,on)
  13.   elseif reactorNumb == 2 then
  14.     rednet.send(254,on)
  15.   elseif reactorNumb == 3 then
  16.     rednet.send(254,on)
  17.   elseif reactorNumb == 4 then
  18.     rednet.send(253,on)
  19.   end
  20. end
  21.  
  22. --System Functions
  23.  
  24. function heat()
  25.  for system,status in pairs(info) do
  26.   status = tostring(status)
  27.   max = 500
  28.   if system == "heat" then
  29.     monitor.setCursorPos(1,3)
  30.     monitor.setTextColor(colors.yellow)
  31.     print("*")
  32.     monitor.setCursorPos(1,5)
  33.     print("*")
  34.     monitor.setTextColor(colors.white)  
  35.     monitor.setCursorPos(2,3)  
  36.     print(" Reactor Heat Level = "..status)
  37.     monitor.setCursorPos(2,5)
  38.     print(" Reactor Max Heat = "..max)
  39.     monitor.setTextColor(colors.yellow)
  40.     monitor.setCursorPos(27,5)
  41.     print("+")
  42.     monitor.setTextColor(colors.white)
  43.     monitor.setCursorPos(28,5)
  44.     print(" or ")
  45.     monitor.setCursorPos(33,5)
  46.     monitor.setTextColor(colors.yellow)
  47.     print("-")
  48.   end
  49.  end
  50. end
  51. function reactorPower()
  52.  for system,status in pairs(info) do
  53.   status = tostring(status)  
  54.   if system == "reactorPoweredB" then
  55.     monitor.setBackgroundColor(colors.yellow)      
  56.     monitor.setTextColor(colors.black)
  57.     monitor.setCursorPos(1,1)
  58.     for name,data in pairs(disk/buttons) do
  59.       local on = data["active"]
  60.       if on == true then
  61.         reactorStatus = "on"
  62.       else
  63.         reactorStatus = "off"
  64.       end
  65.     end
  66.     print("Nuclear Reactor #"..reactorNumb.." = "..reactorStatus)
  67.     monitor.setCursorPos(1,18)
  68.     print("Back")
  69.     monitor.setCursorPos(28,18)
  70.     print("Page Forward")
  71.     monitor.setBackgroundColor(colors.black)
  72.   end
  73.  end
  74. end
  75. function output()
  76.  for system,status in pairs(info) do
  77.   status = tostring(status)  
  78.   if system == "output" then
  79.     monitor.setTextColor(colors.yellow)
  80.     monitor.setCursorPos(1,7)
  81.     print("*")
  82.     monitor.setTextColor(colors.white)
  83.     monitor.setCursorPos(2,7)
  84.     print(" EU Output = "..status)
  85.   end
  86.  end
  87. end
  88. function timeLeft()
  89.  for system,status in pairs(info) do
  90.   status = tostring(status)
  91.   if system == "timeLeft" then
  92.     monitor.setTextColor(colors.yellow)
  93.     monitor.setCursorPos(1,9)
  94.     print("*")
  95.     monitor.setTextColor(colors.white)
  96.     monitor.setCursorPos(2,9)
  97.     print(" Uranium Cells level = "..status)
  98.   end
  99.  end
  100. end
  101. function nuclear(numbNuke)
  102.   noth1, noth2, card, info = nir.get(numbNuke)
  103.   reactorNumb = numbNuke
  104.   term.redirect(monitor)
  105.   monitor.clear()
  106.   monitor.setBackgroundColor(colors.black)
  107.   heat()
  108.   reactorPower()
  109.   output()
  110.   timeLeft()
  111.   term.restore()
  112. end
  113.  
  114. --Load Screen Function
  115.  
  116. local function loadScreen()
  117.   monitor.clear()
  118.   term.redirect(monitor)
  119.   monitor.setTextColor(colors.white)
  120.   monitor.setBackgroundColor(colors.black)
  121.   monitor.setCursorPos(9,1)
  122.   textutils.slowWrite("Nuclear Reactor Controls")
  123.   paintutils.drawImage(nuke,-4,2)
  124.   monitor.setCursorPos(1,15)
  125.   textutils.slowWrite("(Right Click Screen to go edit Reactor)")
  126.   while os.pullEvent("monitor_touch") == false do
  127.     sleep(0)
  128.   end
  129.   monitor.clear()
  130.   term.restore()
  131. end
  132.  
  133. --Load Screen Function
  134.  
  135. loadScreen()
  136.  
  137. --Nuclear #1 Display/Controls
  138.  
  139. nuclear(1)
  140. while true do
  141.   nuclear(1)
  142.   buttonLoop()
  143.   sleep(0)
  144. end
  145. local event,side,xPos,yPos = os.pullEvent("monitor_touch")
Advertisement
Add Comment
Please, Sign In to add comment