Advertisement
Lavieau

MasterOS UserAssembler_Assembler

Oct 22nd, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.77 KB | None | 0 0
  1. --********************************--
  2. --**http://pastebin.com/Gtyeg4fz**--
  3. --********************************--
  4.  
  5. local args = { ... }
  6. os.loadAPI("MasterOS/SystemFile/APIS/ApisLoader")
  7. ApisLoader.UserInfo()
  8. ApisLoader.Vwindow()
  9.  
  10. --*****ColorMenu*****--
  11. local ColorsTXT = {
  12.     "    Chose Your    ",
  13.     "  Favorite Color  ",
  14.     "__________________",
  15.     "|                |",
  16.     "|                |",
  17.     "|                |",
  18.     "|                |",
  19.     "------------------"
  20. }
  21. local ColorsColor = {
  22.     "999999999999999999",
  23.     "999999999999999999",
  24.     "999999999999999999",
  25.     "999999999999999999",
  26.     "999999999999999999",
  27.     "999999999999999999",
  28.     "999999999999999999",
  29.     "999999999999999999"
  30. }
  31. local ColorsTXTColors = {
  32.     "000000000000000000",
  33.     "000000000000000000",
  34.     "000000000000000000",
  35.     "099999999999999990",
  36.     "099999999999999990",
  37.     "099999999999999990",
  38.     "099999999999999990",
  39.     "000000000000000000"
  40. }
  41.  
  42. local White = {
  43.     "00",
  44.     "00"
  45. }
  46. local Orange = {
  47.     "11",
  48.     "11"
  49. }
  50. local Magenta = {
  51.     "22",
  52.     "22"
  53. }
  54. local LightBlue = {
  55.     "33",
  56.     "33"
  57. }
  58. local Yellow = {
  59.     "44",
  60.     "44"
  61. }
  62. local Lime = {
  63.     "55",
  64.     "55"
  65. }
  66. local Pink = {
  67.     "66",
  68.     "66"
  69. }
  70. local Gray = {
  71.     "77",
  72.     "77"
  73. }
  74. local LightGray = {
  75.     "88",
  76.     "88"
  77. }
  78. local Cyan = {
  79.     "99",
  80.     "99"
  81. }
  82. local Purple = {
  83.     "aa",
  84.     "aa"
  85. }
  86. local Blue = {
  87.     "bb",
  88.     "bb"
  89. }
  90. local Brown = {
  91.     "cc",
  92.     "cc"
  93. }
  94. local Green = {
  95.     "dd",
  96.     "dd"
  97. }
  98. local Red = {
  99.     "ee",
  100.     "ee"
  101. }
  102. local Black = {
  103.     "ff",
  104.     "ff"
  105. }
  106.  
  107. function CreateColorsMenu ()
  108.     xCoor = 15
  109.     yCoor = 5
  110.     ColorMenu = window.create(term.current(), xCoor + 1, yCoor, 18, 8)
  111.     Vwindow.addTableToWindowBlit(ColorMenu, ColorsTXT, ColorsTXTColors, ColorsColor, 1, 1, 0)
  112.    
  113.     WindWhite = window.create(term.current(), xCoor + 2, yCoor + 3, 2, 2)
  114.     Vwindow.addTableToWindowBlit(WindWhite, White, White, White, 1, 1, 0)
  115.     WindOrange = window.create(term.current(), xCoor + 4, yCoor + 3, 2, 2)
  116.     Vwindow.addTableToWindowBlit(WindOrange, Orange, Orange, Orange, 1, 1, 0)
  117.     WindMagenta = window.create(term.current(), xCoor + 6, yCoor + 3, 2, 2)
  118.     Vwindow.addTableToWindowBlit(WindMagenta, Magenta, Magenta, Magenta, 1, 1, 0)
  119.     WindLightBlue = window.create(term.current(), xCoor + 8, yCoor + 3, 2, 2)
  120.     Vwindow.addTableToWindowBlit(WindLightBlue, LightBlue, LightBlue, LightBlue, 1, 1, 0)
  121.     WindYellow = window.create(term.current(), xCoor + 10, yCoor + 3, 2, 2)
  122.     Vwindow.addTableToWindowBlit(WindYellow, Yellow, Yellow, Yellow, 1, 1, 0)
  123.     WindLime = window.create(term.current(), xCoor + 12, yCoor + 3, 2, 2)
  124.     Vwindow.addTableToWindowBlit(WindLime, Lime, Lime, Lime, 1, 1, 0)
  125.     WindPink = window.create(term.current(), xCoor + 14, yCoor + 3, 2, 2)
  126.     Vwindow.addTableToWindowBlit(WindPink, Pink, Pink, Pink, 1, 1, 0)
  127.     WindGray = window.create(term.current(), xCoor + 16, yCoor + 3, 2, 2)
  128.     Vwindow.addTableToWindowBlit(WindGray, Gray, Gray, Gray, 1, 1, 0)
  129.     WindLightGray = window.create(term.current(), xCoor + 2, yCoor + 5, 2, 2)
  130.     Vwindow.addTableToWindowBlit(WindLightGray, LightGray, LightGray, LightGray, 1, 1, 0)
  131.     WindCyan = window.create(term.current(), xCoor + 4, yCoor + 5, 2, 2)
  132.     Vwindow.addTableToWindowBlit(WindCyan, Cyan, Cyan, Cyan, 1, 1, 0)
  133.     WindPurple = window.create(term.current(), xCoor + 6, yCoor + 5, 2, 2)
  134.     Vwindow.addTableToWindowBlit(WindPurple, Purple, Purple, Purple, 1, 1, 0)
  135.     WindBlue = window.create(term.current(), xCoor + 8, yCoor + 5, 2, 2)
  136.     Vwindow.addTableToWindowBlit(WindBlue, Blue, Blue, Blue, 1, 1, 0)
  137.     WindBrown = window.create(term.current(), xCoor + 10, yCoor + 5, 2, 2)
  138.     Vwindow.addTableToWindowBlit(WindBrown, Brown, Brown, Brown, 1, 1, 0)
  139.     WindGreen = window.create(term.current(), xCoor + 12, yCoor + 5, 2, 2)
  140.     Vwindow.addTableToWindowBlit(WindGreen, Green, Green, Green, 1, 1, 0)
  141.     WindRed = window.create(term.current(), xCoor + 14, yCoor + 5, 2, 2)
  142.     Vwindow.addTableToWindowBlit(WindRed, Red, Red, Red, 1, 1, 0)
  143.     WindBlack = window.create(term.current(), xCoor + 16, yCoor + 5, 2, 2)
  144.     Vwindow.addTableToWindowBlit(WindBlack, Black, Black, Black, 1, 1, 0)
  145. end
  146. --*******************--
  147.  
  148. local names = {}
  149. local function LoadUserName()
  150.     if fs.exists("MasterOS/Users/UserList") then
  151.         userListFile = fs.open("MasterOS/Users/UserList", "r")
  152.        
  153.         numb = 0
  154.         while numb ~= 10 do
  155.             TxtVar = userListFile.readLine()
  156.             names[numb + 1] = TxtVar
  157.             numb = numb + 1
  158.         end
  159.         userListFile.close()
  160.     else
  161.        
  162.     end
  163. end
  164.  
  165.  
  166. --Window
  167. local function GenerateWindow()
  168.     Entry = window.create(term.current(), 16, 7, 18, 4)
  169. end
  170.  
  171. local function RebuiltWindow(Title)
  172.     Entry.setBackgroundColor(colors.cyan)
  173.     Entry.clear()
  174.     Entry.setTextColor(colors.white)
  175.     Entry.setCursorPos(2, 2)
  176.     Entry.write(Title)
  177.     Entry.setCursorPos(2, 3)
  178.     Entry.setBackgroundColor(colors.lightGray)
  179.     Entry.write("                ")
  180.     Entry.setCursorPos(2, 3)
  181.     Entry.setCursorBlink(true)
  182. end
  183.  
  184.  
  185. function EnterYourName()
  186.     RebuiltWindow("Enter Your Name:")
  187.    
  188.     local go = true
  189.     local first = true
  190.     while go do
  191.         if first == false then
  192.         Entry.setCursorPos(2, 3)
  193.         Entry.setBackgroundColor(colors.lightGray)
  194.         Entry.setTextColor(colors.gray)
  195.         Entry.write(" Already Use    ")
  196.         Entry.setCursorPos(2, 3)
  197.         Entry.setTextColor(colors.white)
  198.         end
  199.         first = false
  200.        
  201.         term.setBackgroundColor(colors.lightGray)
  202.          InName = read()
  203.  
  204.        
  205.         Good = true
  206.         for k,v in ipairs(names) do
  207.             NamesLowerCase = string.lower(names[k])
  208.             InNameLowerCase = string.lower(InName)
  209.            
  210.             Space = string.find(NamesLowerCase, " ")
  211.             if (InNameLowerCase == NamesLowerCase) or (InNameLowerCase == nil) or (Space == 1) then
  212.                 Good = false
  213.             end
  214.         end
  215.        
  216.         if Good == true then
  217.             go = false
  218.         end
  219.     end
  220.    
  221.     return InName
  222. end
  223.  
  224.  function EnterPassword()
  225.     local go = true
  226.     while go do
  227.        
  228.         RebuiltWindow("Enter Password:")
  229.         FirstPass = read("*")
  230.  
  231.         RebuiltWindow("Repeat Password:")
  232.         SecondPass = read("*")
  233.        
  234.         if FirstPass == SecondPass then
  235.             go = false
  236.         else
  237.             RebuiltWindow("The 2 Password")
  238.             Entry.write("Don't correspond")
  239.             os.sleep(5)
  240.         end
  241.     end
  242.    
  243.     return FirstPass
  244. end
  245.  
  246.  function CreateUserPicture()
  247.  
  248. end
  249.  
  250. SelectedColors = "blue"
  251. local function FWhite()
  252.     Vwindow.clickOn(WindWhite)
  253.     SelectedColors = "white"
  254.     return("white")
  255. end
  256. local function FOrange()
  257.     Vwindow.clickOn(WindOrange)
  258.     SelectedColors = "orange"
  259.     return("orange")
  260. end
  261. local function FMagenta()
  262.     Vwindow.clickOn(WindMagenta)
  263.     SelectedColors = "magenta"
  264. end
  265. local function FLightBlue()
  266.     Vwindow.clickOn(WindLightBlue)
  267.     SelectedColors = "lightBlue"
  268. end
  269. local function FYellow()
  270.     Vwindow.clickOn(WindYellow)
  271.     SelectedColors = "yellow"
  272. end
  273. local function FLime()
  274.     Vwindow.clickOn(WindLime)
  275.     SelectedColors = "lime"
  276. end
  277. local function FPink()
  278.     Vwindow.clickOn(WindPink)
  279.     SelectedColors = "pink"
  280. end
  281. local function FGray()
  282.     Vwindow.clickOn(WindGray)
  283.     SelectedColors = "gray"
  284. end
  285. local function FLightGray()
  286.     Vwindow.clickOn(WindLightGray)
  287.     SelectedColors = "lightGray"
  288. end
  289. local function FCyan()
  290.     Vwindow.clickOn(WindCyan)
  291.     SelectedColors = "cyan"
  292. end
  293. local function FPurple()
  294.     Vwindow.clickOn(WindPurple)
  295.     SelectedColors = "purple"
  296. end
  297. local function FBlue()
  298.     Vwindow.clickOn(WindBlue)
  299.     SelectedColors = "blue"
  300. end
  301. local function FBrown()
  302.     Vwindow.clickOn(WindBrown)
  303.     SelectedColors = "brown"
  304. end
  305. local function FGreen()
  306.     Vwindow.clickOn(WindGreen)
  307.     SelectedColors = "green"
  308. end
  309. local function FRed()
  310.     Vwindow.clickOn(WindRed)
  311.     --SelectedColors = "red"
  312.     return("red")
  313. end
  314. local function FBlack()
  315.     Vwindow.clickOn(WindBlack)
  316.     SelectedColors = "black"
  317. end
  318.  
  319.  function ChoseFColor()
  320.     CreateColorsMenu()
  321.     --parallel.waitForAny(FWhite, FOrange)--, FMagenta, FLightBlue,FYellow, FLime, FPink, FGray,FLightGray, FCyan, FPurple, FBlue,FBrown, FGreen, FRed, FBlack)
  322.    
  323.     --*****White*****--
  324.     WhiteXPos, WhiteYPos = WindWhite.getPosition()
  325.     WhiteX, WhiteY = WindWhite.getSize()
  326.     Whitelenght = WhiteXPos + WhiteX
  327.     Whitewight = WhiteYPos + WhiteY
  328.     -- --*****Orange*****--
  329.     OrangeXPos, OrangeYPos = WindOrange.getPosition()
  330.     OrangeX, OrangeY = WindOrange.getSize()
  331.     Orangelenght = OrangeXPos + OrangeX
  332.     Orangewight = OrangeYPos + OrangeY
  333.     --*****Magenta*****--
  334.     MagentaXPos, MagentaYPos = WindMagenta.getPosition()
  335.     MagentaX, MagentaY = WindMagenta.getSize()
  336.     Magentalenght = MagentaXPos + MagentaX
  337.     Magentawight = MagentaYPos + MagentaY
  338.     --*****LightBlue*****--
  339.     LightBlueXPos, LightBlueYPos = WindLightBlue.getPosition()
  340.     LightBlueX, LightBlueY = WindLightBlue.getSize()
  341.     LightBluelenght = LightBlueXPos + LightBlueX
  342.     LightBluewight = LightBlueYPos + LightBlueY
  343.     --*****Yellow*****--
  344.     YellowXPos, YellowYPos = WindYellow.getPosition()
  345.     YellowX, YellowY = WindYellow.getSize()
  346.     Yellowlenght = YellowXPos + YellowX
  347.     Yellowwight = YellowYPos + YellowY
  348.     --*****Lime*****--
  349.     LimeXPos, LimeYPos = WindLime.getPosition()
  350.     LimeX, LimeY = WindLime.getSize()
  351.     Limelenght = LimeXPos + LimeX
  352.     Limewight = LimeYPos + LimeY
  353.     --*****Pink*****--
  354.     PinkXPos, PinkYPos = WindPink.getPosition()
  355.     PinkX, PinkY = WindPink.getSize()
  356.     Pinklenght = PinkXPos + PinkX
  357.     Pinkwight = PinkYPos + PinkY
  358.     --*****Gray*****--
  359.     GrayXPos, GrayYPos = WindGray.getPosition()
  360.     GrayX, GrayY = WindGray.getSize()
  361.     Graylenght = GrayXPos + GrayX
  362.     Graywight = GrayYPos + GrayY
  363.     --*****LightGray*****--
  364.     LightGrayXPos, LightGrayYPos = WindLightGray.getPosition()
  365.     LightGrayX, LightGrayY = WindLightGray.getSize()
  366.     LightGraylenght = LightGrayXPos + LightGrayX
  367.     LightGraywight = LightGrayYPos + LightGrayY
  368.     --*****Cyan*****--
  369.     CyanXPos, CyanYPos = WindCyan.getPosition()
  370.     CyanX, CyanY = WindCyan.getSize()
  371.     Cyanlenght = CyanXPos + CyanX
  372.     Cyanwight = CyanYPos + CyanY
  373.     --*****Purple*****--
  374.     PurpleXPos, PurpleYPos = WindPurple.getPosition()
  375.     PurpleX, PurpleY = WindPurple.getSize()
  376.     Purplelenght = PurpleXPos + PurpleX
  377.     Purplewight = PurpleYPos + PurpleY
  378.     --*****Blue*****--
  379.     BlueXPos, BlueYPos = WindBlue.getPosition()
  380.     BlueX, BlueY = WindBlue.getSize()
  381.     Bluelenght = BlueXPos + BlueX
  382.     Bluewight = BlueYPos + BlueY
  383.     --*****Brown*****--
  384.     BrownXPos, BrownYPos = WindBrown.getPosition()
  385.     BrownX, BrownY = WindBrown.getSize()
  386.     Brownlenght = BrownXPos + BrownX
  387.     Brownwight = BrownYPos + BrownY
  388.     --*****Green*****--
  389.     GreenXPos, GreenYPos = WindGreen.getPosition()
  390.     GreenX, GreenY = WindGreen.getSize()
  391.     Greenlenght = GreenXPos + GreenX
  392.     Greenwight = GreenYPos + GreenY
  393.     --*****Red*****--
  394.     RedXPos, RedYPos = WindRed.getPosition()
  395.     RedX, RedY = WindRed.getSize()
  396.     Redlenght = RedXPos + RedX
  397.     Redwight = RedYPos + RedY
  398.     --*****Black*****--
  399.     BlackXPos, BlackYPos = WindBlack.getPosition()
  400.     BlackX, BlackY = WindBlack.getSize()
  401.     Blacklenght = BlackXPos + BlackX
  402.     Blackwight = BlackYPos + BlackY
  403.    
  404.     while true do
  405.         event, side, xCoor, yCoor = os.pullEvent("mouse_click")
  406.         --*****White*****--
  407.         if (xCoor >= WhiteXPos) and (xCoor <= Whitelenght) and (yCoor >= WhiteYPos) and (yCoor <= Whitewight) then
  408.             return("white")
  409.         --*****Orange*****--
  410.         elseif (xCoor >= OrangeXPos) and (xCoor <= Orangelenght) and (yCoor >= OrangeYPos) and (yCoor <= Orangewight) then
  411.             return("orange")
  412.         --*****Magenta*****--
  413.         elseif (xCoor >= MagentaXPos) and (xCoor <= Magentalenght) and (yCoor >= MagentaYPos) and (yCoor <= Magentawight) then
  414.             return("magenta")
  415.         --*****LightBlue*****--
  416.         elseif (xCoor >= LightBlueXPos) and (xCoor <= LightBluelenght) and (yCoor >= LightBlueYPos) and (yCoor <= LightBluewight) then
  417.             return("lightBlue")
  418.         --*****Yellow*****--
  419.         elseif (xCoor >= YellowXPos) and (xCoor <= Yellowlenght) and (yCoor >= YellowYPos) and (yCoor <= Yellowwight) then
  420.             return("yellow")
  421.         --*****Lime*****--
  422.         elseif (xCoor >= LimeXPos) and (xCoor <= Limelenght) and (yCoor >= LimeYPos) and (yCoor <= Limewight) then
  423.             return("lime")
  424.         --*****Pink*****--
  425.         elseif (xCoor >= PinkXPos) and (xCoor <= Pinklenght) and (yCoor >= PinkYPos) and (yCoor <= Pinkwight) then
  426.             return("pink")
  427.         --*****Gray*****--
  428.         elseif (xCoor >= GrayXPos) and (xCoor <= Graylenght) and (yCoor >= GrayYPos) and (yCoor <= Graywight) then
  429.             return("gray")
  430.         --*****LightGray*****--
  431.         elseif (xCoor >= LightGrayXPos) and (xCoor <= LightGraylenght) and (yCoor >= LightGrayYPos) and (yCoor <= LightGraywight) then
  432.             return("lightGray")
  433.         --*****Cyan*****--
  434.         elseif (xCoor >= CyanXPos) and (xCoor <= Cyanlenght) and (yCoor >= CyanYPos) and (yCoor <= Cyanwight) then
  435.             return("cyan")
  436.         --*****Purple*****--
  437.         elseif (xCoor >= PurpleXPos) and (xCoor <= Purplelenght) and (yCoor >= PurpleYPos) and (yCoor <= Purplewight) then
  438.             return("purple")
  439.         --*****Blue*****--
  440.         elseif (xCoor >= BlueXPos) and (xCoor <= Bluelenght) and (yCoor >= BlueYPos) and (yCoor <= Bluewight) then
  441.             return("blue")
  442.         --*****Brown*****--
  443.         elseif (xCoor >= BrownXPos) and (xCoor <= Brownlenght) and (yCoor >= BrownYPos) and (yCoor <= Brownwight) then
  444.             return("brown")
  445.         --*****Green*****--
  446.         elseif (xCoor >= GreenXPos) and (xCoor <= Greenlenght) and (yCoor >= GreenYPos) and (yCoor <= Greenwight) then
  447.             return("green")
  448.         --*****Red*****--
  449.         elseif (xCoor >= RedXPos) and (xCoor <= Redlenght) and (yCoor >= RedYPos) and (yCoor <= Redwight) then
  450.             return("red")
  451.         --*****Black*****--
  452.         elseif (xCoor >= BlackXPos) and (xCoor <= Blacklenght) and (yCoor >= BlackYPos) and (yCoor <= Blackwight) then
  453.             return("black")
  454.         end
  455.     end
  456. end
  457.  
  458. LoadUserName()
  459.  
  460. GenerateWindow()
  461. UserName = EnterYourName()
  462. User = UserName
  463.  
  464. fs.copy("MasterOS/Users/UserAssembler/DefaultUserDictory/Info", "MasterOS/Users/"..UserName.."/Info")
  465. UserInfo.setName(User, UserName)
  466. UserInfo.setPassword(User, EnterPassword())
  467. --UserInfo.setPicture(User, CreateUserPicture())
  468. FinalColor = ChoseFColor()
  469. UserInfo.setFColor(User, FinalColor)
  470.  
  471.  
  472. names[tonumber(args[1])] = UserName
  473. userFile = fs.open("MasterOS/Users/UserList", "w")
  474.     userFile.flush()
  475.    
  476.     for k,v in ipairs(names) do
  477.         userFile.writeLine(v)
  478.     end
  479.     userFile.close()
  480.  
  481. term.setCursorPos(1,1) 
  482.    
  483. --***************************--
  484. --**Create By:Vieau      2016--
  485. --***************************--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement