Guest User

grid

a guest
Dec 24th, 2014
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.34 KB | None | 0 0
  1. cPrint = function(text)
  2.         local x2,y2 = term.getCursorPos()
  3.         local x,y = term.getSize()
  4.         term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  5.        
  6.         textutils.slowPrint(text)
  7.        
  8. end
  9.  
  10. cPrint2 = function(text)
  11.         local x2,y2 = term.getCursorPos()
  12.         local x,y = term.getSize()
  13.         term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  14.  
  15.         print(text)
  16.        
  17. end  
  18.  
  19. term.clear()
  20. term.setCursorPos(1,1)
  21. cPrint("Hello, welcome to NYT head computer.")
  22.       while true do
  23. cPrint("Enter editor name")
  24. EN = read()
  25. if fs.exists("Editors/" ..EN) == true then
  26. file = fs.open("Editors/" ..EN, "r")
  27. local fileData = {}
  28. local line = file.readLine()
  29. repeat
  30. table.insert(fileData,line)
  31. line = file.readLine()
  32. until line == nil
  33. file.close()
  34. local PassFile = fileData[1]
  35.         break
  36. else
  37.        cPrint("No Editor Found... Create One?")
  38.               sleep(1)
  39.               yyN()
  40.                 end
  41.                 end
  42.                 local PW = false
  43.            repeat    
  44.        cPrint("Please insert Password")
  45. local pss = read()
  46.       if pss == PassFile or PW then
  47.             cPrint("Welcome!")
  48.                     break
  49.        else
  50.              cPrint("Wrong Pass..")
  51.                          end
  52.                  until pss == PassFile
  53.                
  54.                
  55.                                    
  56.  
  57.    
  58. -----Start Buttons----------------
  59. os.loadAPI("gridAPI")
  60. local bob = true
  61. local run = true
  62.  
  63. gridAPI.setRowCount(3) --three rows, holla
  64. gridAPI.setColumnCount(2) --Only 2 Colums? Lame
  65. gridAPI.setWindowColor(colors.black) --Window is black,racist
  66.  
  67. local mainButton = gridAPI.Button:new() --Look, a fuction
  68. mainButton.name = "mainButton" --You too were named at birth
  69. mainButton.text = "RedNet" --It's the text
  70. mainButton.textColor = colors.black --Again, text color is racist
  71. mainButton.backColor = colors.red --The button is red now
  72. mainButton.gridX = 1 --You got me. Idk what this is
  73. mainButton.gridY = 1 --Still don't know...
  74.  
  75. local Monitor = gridAPI.Button:new()
  76. Monitor.name = "Monitor"
  77. Monitor.text = "Monitor Controls"
  78. Monitor.textColor = colors.black
  79. Monitor.backColor = colors.red
  80. Monitor.gridX = 1
  81. Monitor.gridY = 3
  82.  
  83. function mainButton:leftClicked()
  84.       bob = false
  85.       run = false
  86.         end
  87.  
  88. function Monitor:leftClicked()
  89.         self.text = "No"
  90.               end
  91.  -- local updateCount = 0 --obviously updateCount is 0
  92.    --     function mainButton:asyncUpdate() --wat
  93.      --   updateCount = updateCount + 1 --So it updated I think
  94.        -- self.text = "Right click to see the truth(" ..updateCount .. ")" --Oh I get it it's a time
  95.        -- end
  96.             local color = {
  97.                   colors.white,
  98.                   colors.blue,
  99.                   colors.green,
  100.                   colors,red,
  101.                   colors.orange,
  102.                   colors.pink }
  103.                  
  104.         gridAPI.addButton(mainButton)
  105.         gridAPI.addButton(Monitor)
  106.           while run do
  107.                   gridAPI.handleEventAsync()
  108.                       end
  109.            while not run and not bob do
  110.                    shell.run("rednet")
  111.                        break
  112.                          end
  113.           term.clear()
  114.          
  115.           term.setCursorPos(1,1)
Advertisement
Add Comment
Please, Sign In to add comment