Guest User

reactorControl

a guest
Dec 24th, 2015
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. --Variables
  2. mon = peripheral.wrap("right")
  3. reactor = peripheral.wrap("back")
  4. fuelAmount = reactor.getFuelAmount()
  5. maxFuel = reactor.getFuelAmountMax()
  6. ELT = reactor.getEnergyProducedLastTick()
  7. fuelReactivity = reactor.getFuelReactivity()
  8. --functions
  9.  
  10. function reset()
  11.  mon.clear()
  12.  mon.setCursorPos(1,1)
  13. end
  14.  
  15.  
  16. function gui()
  17.  reset()
  18.  mon.setCursorPos(1,1)
  19.   if reactor.getActive == true then
  20.    print("Reactor On")
  21.   else
  22.    print("Reactor Off")
  23.   end
  24.  print("Fuel:"..fuelAmount.."/"..maxFuel)
  25.  print("RF/t:"..ELT)
  26.  print("Reactivity:".. fuelReactivity.."%")
  27.  mon.setCursorPos(1,11)
  28.  print("Reactor ON/OFF")
  29. end
  30.  
  31. --Main Program
  32. reset()
  33. gui()
  34. os.pullEvent()
  35. touch = {os.pullEvent()}
  36. event = touch[1]
  37. side = touch[2]
  38. xPos = touch[3]
  39. yPos = touch[4]
  40. mon.setCursorPos(1,12)
  41. print(event)
  42. print(side)
  43. print(xPos)
  44. print(yPos)
  45.  
  46. while true do
  47.  if event == monitor_touch and xPos >= 1 and xPos <= 14 and yPos == 11 then
  48.   if reactor.getActive() == true then
  49.    reactor.setActive(false)
  50.    gui()
  51.   elseif reactor.getActive() == false then
  52.    reactor.setActive(true)
  53.    gui()
  54.   end
  55.  end
  56. end
Advertisement
Add Comment
Please, Sign In to add comment