xxangel17xx

INPUT>Output-Monitor

Mar 19th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.82 KB | None | 0 0
  1. --=========================================================================================================
  2. --DoNot remove this Credits
  3. --Created On 19th MARCH 2014
  4. --by Angel_Code http://www.computercraft.info/forums2/index.php?/user/18955-angel-code/
  5. --Support Provided By theoriginalbit http://computercraft.theoriginalbit.com/
  6. --Support Provided By Bomb Bloke http://www.computercraft.info/forums2/index.php?/user/15121-bomb-bloke/
  7. --=========================================================================================================
  8. Mon = peripheral.wrap("top")  --Change "top" to the side the monitor is on.
  9. local function centerText(text)
  10.   x,y = Mon.getSize()
  11.   x1,y1 = Mon.getCursorPos()
  12.   Mon.setCursorPos((math.floor(x/2) - (math.floor(#text/2))), y1)
  13.   Mon.write(text)  
  14. end
  15.  
  16. local function defence()
  17.     Mon.clear()
  18.     Mon.setCursorPos(1, 1)
  19.     centerText("=========================================")
  20.     Mon.setCursorPos(1, 2)
  21.     centerText("WARNING!")
  22.     Mon.setCursorPos(1, 3)
  23.     centerText("INCOMING MISSILE")
  24.     Mon.setCursorPos(1, 4)
  25.     centerText("ACTIVATING FORCEFIELD")
  26.     redstone.setOutput("right", true) --Change "right" to the OUTPUT side.
  27.     Mon.setCursorPos(1, 6)
  28.     centerText("=========================================")
  29.  
  30.     local count = 60 -- Change 60 to the amout of time in seconds a redstone signal should be turned on for.
  31. while true do
  32.   Mon.setCursorPos(1, 5)
  33.   centerText("Field Active For " ..count.. " Seconds")
  34.   sleep(0.5)
  35.   count = count - 1
  36.   if count < 0 then
  37.     redstone.setOutput("right", false) --Change "right" to the OUTPUT side.
  38.     Mon.clear()
  39.     check()
  40.   end
  41. end
  42. end
  43.  
  44. function check()
  45.  while true do
  46.    if redstone.getInput("left") then defence() end  -- Change "left" to the INPUT side.
  47.       os.pullEvent("redstone")
  48.    end
  49. end
  50.  
  51. check()
Advertisement
Add Comment
Please, Sign In to add comment