Advertisement
Guest User

startup

a guest
Jan 24th, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. reactor = peripheral.wrap("back")
  2. mon = peripheral.wrap("bottom")
  3. term.redirect(mon)
  4. function parse(cmd)
  5.   if cmd == "activate" then
  6.     reactor.setActive(true)
  7.   elseif cmd == "deactivate" then
  8.     reactor.setActive(false)
  9.   elseif cmd == "exit" then
  10.     exit = true
  11.   end
  12. end
  13.  
  14. function main()
  15.   term.setCursorPos(1,1)
  16.   if reactor.getActive() then
  17.     term.setBackgroundColor(colors.green)
  18.     term.setTextColor(colors.blue)
  19.     term.clear()
  20.     mon.setTextScale(1)
  21.     term.write("Active")
  22.   else
  23.     term.setBackgroundColor(colors.red)
  24.     term.setTextColor(colors.blue)
  25.     term.clear()
  26.     mon.setTextScale(2)
  27.     term.write("   INACTIVE")
  28.   end
  29.   term.setCursorPos(1,2)
  30.   --mon.setTextScale(1)
  31.   term.write("Command:")
  32.   cmd = io.read()
  33.   parse(cmd)
  34. end
  35.  
  36. function timer()
  37.   local myTimer = os.startTimer(10)
  38.   while true do
  39.     local event,timerID = os.pullEvent("timer")
  40.     if timerID == myTimer then break end
  41.   end
  42. end
  43.  
  44. repeat
  45.   parallel.waitForAny(main,timer)
  46. until exit
  47.  
  48. term.restore()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement