Advertisement
wv1106

wildroid

Feb 21st, 2022 (edited)
913
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.05 KB | None | 0 0
  1. -- Hi i am wv1106, the creator of wildroid
  2. -- If you while reading the code find any problems or bad practices please let me know
  3. -- I am self tought and still trying to learn =D
  4.  
  5. local number = 0
  6. local password = "0000"
  7. local enterd = ""
  8. local bgColor = colors.cyan
  9.  
  10. if fs.exists("password") then       --reads the password
  11.     local file = fs.open("password", "r")
  12.     password = file.readAll()
  13.     file.close()
  14. else
  15.     local file = fs.open("password", "w")
  16.     file.write("0000")
  17.     file.close()
  18. end
  19.  
  20. term.setBackgroundColor(bgColor)    --paints the lockscreen
  21. term.clear()
  22. paintutils.drawFilledBox(5, 3, 9, 5, colors.lightGray)
  23. term.setCursorPos(7, 4)
  24. term.write("7")
  25. paintutils.drawFilledBox(12, 3, 16, 5, colors.lightGray)
  26. term.setCursorPos(14, 4)
  27. term.write("8")
  28. paintutils.drawFilledBox(19, 3, 23, 5, colors.lightGray)
  29. term.setCursorPos(21, 4)
  30. term.write("9")
  31. paintutils.drawFilledBox(5, 7, 9, 9, colors.lightGray)
  32. term.setCursorPos(7, 8)
  33. term.write("4")
  34. paintutils.drawFilledBox(12, 7, 16, 9, colors.lightGray)
  35. term.setCursorPos(14, 8)
  36. term.write("5")
  37. paintutils.drawFilledBox(19, 7, 23, 9, colors.lightGray)
  38. term.setCursorPos(21, 8)
  39. term.write("6")
  40. paintutils.drawFilledBox(5, 11, 9, 13, colors.lightGray)
  41. term.setCursorPos(7, 12)
  42. term.write("1")
  43. paintutils.drawFilledBox(12, 11, 16, 13, colors.lightGray)
  44. term.setCursorPos(14, 12)
  45. term.write("2")
  46. paintutils.drawFilledBox(19, 11, 23, 13, colors.lightGray)
  47. term.setCursorPos(21, 12)
  48. term.write("3")
  49. paintutils.drawFilledBox(12, 15, 16, 17, colors.lightGray)
  50. term.setCursorPos(14, 16)
  51. term.write("0")
  52.  
  53. while 1 do      --verifies the password
  54.     local event = {os.pullEventRaw()}   --os.pullEventRaw to stop terminating the program
  55.     if event[1]=="mouse_click" then
  56.         if event[2]==1 then
  57.             number = 0
  58.             if event[3]>=5 and event[3]<=9 then
  59.                 number = 1
  60.             elseif event[3]>=12 and event[3]<=16 then
  61.                 number = 2
  62.             elseif event[3]>=19 and event[3]<=23 then
  63.                 number = 3
  64.             end
  65.             if event[4]>=3 and event[4]<=5 then
  66.                 number = number+6
  67.             elseif event[4]>=7 and event[4]<=9 then
  68.                 number = number+3
  69.             elseif event[4]>=15 and event[4]<=17 then
  70.                 number = 0
  71.             end
  72.             enterd = enterd..tostring(number)
  73.            
  74.         end
  75.        
  76.     end
  77.     if #enterd >= 4 then
  78.         if enterd == password then
  79.             break
  80.         else
  81.             os.reboot()
  82.         end
  83.     end
  84. end
  85.  
  86. function redrawUI() --redraws the homepage
  87.     term.setTextColor(colors.white)
  88.     term.setBackgroundColor(bgColor)
  89.     term.clear()
  90.     term.setCursorPos(1, 1)
  91.  
  92.     paintutils.drawFilledBox(2, 8, 8, 12, colors.black)
  93.     paintutils.drawLine(3, 9, 7, 9, colors.red)
  94.     paintutils.drawLine(6, 10, 7, 10, colors.red)
  95.     paintutils.drawLine(3, 11, 4, 11, colors.magenta)
  96.     term.setBackgroundColor(bgColor)
  97.     term.setCursorPos(2, 13)
  98.     term.write("falling")
  99.  
  100.     paintutils.drawFilledBox(10, 2, 16, 6, colors.gray)
  101.     paintutils.drawLine(13, 3, 13, 5, colors.white)
  102.     paintutils.drawLine(12, 4, 14, 4, colors.white)
  103.     paintutils.drawLine(11, 3, 15, 3, colors.white)
  104.     term.setBackgroundColor(bgColor)
  105.     term.setCursorPos(10, 7)
  106.     term.write("update")
  107.  
  108.     paintutils.drawFilledBox(18, 2, 24, 6, colors.gray)
  109.     paintutils.drawPixel(21, 3, colors.white)
  110.     paintutils.drawPixel(22, 4, colors.white)
  111.     paintutils.drawPixel(21, 5, colors.white)
  112.     term.setBackgroundColor(bgColor)
  113.     term.setCursorPos(20, 7)
  114.     term.write("lua")
  115.  
  116.     paintutils.drawFilledBox(2, 2, 8, 6, colors.gray)
  117.     paintutils.drawFilledBox(4, 5, 6, 5, colors.yellow)
  118.     paintutils.drawPixel(4, 4, colors.lightGray)
  119.     paintutils.drawPixel(6, 4, colors.lightGray)
  120.     paintutils.drawLine(4, 3, 6, 3, colors.lightGray)
  121.  
  122.     term.setBackgroundColor(bgColor)
  123.     term.setCursorPos(2, 7)
  124.     term.write("pincode")
  125.  
  126.     paintutils.drawFilledBox(10, 8, 16, 12, colors.black)
  127.     paintutils.drawLine(11, 9, 13, 9, colors.green)
  128.     paintutils.drawPixel(15, 9, colors.red)
  129.     term.setBackgroundColor(bgColor)
  130.     term.setCursorPos(10, 13)
  131.     term.write("snake")
  132.  
  133.  
  134.     paintutils.drawLine(1, 20, 26, 20, colors.lightGray)
  135.     term.setCursorPos(2, 20)
  136.     term.write(textutils.formatTime(os.time("local")))
  137. end
  138.  
  139. local event = {}
  140.  
  141. function getKeyPress() -- a function for parallel on line 154
  142.     event = {os.pullEventRaw()}
  143.     return
  144. end
  145.  
  146. function timeOut() -- a function for parallel on line 154
  147.     sleep(1)
  148.     return
  149. end
  150.  
  151. while 1 do  -- the main loop of the homepage
  152.     redrawUI()
  153.     event = {}
  154.     parallel.waitForAny(getKeyPress, timeOut)
  155.    
  156.     if event[1]=="mouse_click" then
  157.         if event[2]==1 then
  158.             number = 0
  159.             if event[3]>=2 and event[3]<=8 then
  160.                 number = 1
  161.             elseif event[3]>=10 and event[3]<=16 then
  162.                 number = 2
  163.             elseif event[3]>=18 and event[3]<=24 then
  164.                 number = 3
  165.             else
  166.                 number = 0
  167.             end
  168.             if event[4]>=2 and event[4]<=6 then
  169.                 number = number
  170.             elseif event[4]>=8 and event[4]<=12 then
  171.                 number = number+3
  172.             else
  173.                 number = 0
  174.             end
  175.             if number == 1 then
  176.  
  177.                 term.setBackgroundColor(bgColor)
  178.                 term.clear()
  179.                 paintutils.drawFilledBox(5, 3, 9, 5, colors.lightGray)
  180.                 term.setCursorPos(7, 4)
  181.                 term.write("7")
  182.                 paintutils.drawFilledBox(12, 3, 16, 5, colors.lightGray)
  183.                 term.setCursorPos(14, 4)
  184.                 term.write("8")
  185.                 paintutils.drawFilledBox(19, 3, 23, 5, colors.lightGray)
  186.                 term.setCursorPos(21, 4)
  187.                 term.write("9")
  188.                 paintutils.drawFilledBox(5, 7, 9, 9, colors.lightGray)
  189.                 term.setCursorPos(7, 8)
  190.                 term.write("4")
  191.                 paintutils.drawFilledBox(12, 7, 16, 9, colors.lightGray)
  192.                 term.setCursorPos(14, 8)
  193.                 term.write("5")
  194.                 paintutils.drawFilledBox(19, 7, 23, 9, colors.lightGray)
  195.                 term.setCursorPos(21, 8)
  196.                 term.write("6")
  197.                 paintutils.drawFilledBox(5, 11, 9, 13, colors.lightGray)
  198.                 term.setCursorPos(7, 12)
  199.                 term.write("1")
  200.                 paintutils.drawFilledBox(12, 11, 16, 13, colors.lightGray)
  201.                 term.setCursorPos(14, 12)
  202.                 term.write("2")
  203.                 paintutils.drawFilledBox(19, 11, 23, 13, colors.lightGray)
  204.                 term.setCursorPos(21, 12)
  205.                 term.write("3")
  206.                 paintutils.drawFilledBox(12, 15, 16, 17, colors.lightGray)
  207.                 term.setCursorPos(14, 16)
  208.                 term.write("0")
  209.                 enterd = ""
  210.                 while 1 do
  211.                     local event = {os.pullEventRaw()}
  212.                     if event[1]=="mouse_click" then
  213.                         if event[2]==1 then
  214.                             number = 0
  215.                             if event[3]>=5 and event[3]<=9 then
  216.                                 number = 1
  217.                             elseif event[3]>=12 and event[3]<=16 then
  218.                                 number = 2
  219.                             elseif event[3]>=19 and event[3]<=23 then
  220.                                 number = 3
  221.                             end
  222.                             if event[4]>=3 and event[4]<=5 then
  223.                                 number = number+6
  224.                             elseif event[4]>=7 and event[4]<=9 then
  225.                                 number = number+3
  226.                             elseif event[4]>=15 and event[4]<=17 then
  227.                                 number = 0
  228.                             end
  229.                             enterd = enterd..tostring(number)
  230.                            
  231.                         end
  232.                        
  233.                     end
  234.                     if #enterd >= 4 then
  235.                         password = enterd
  236.                         local file = fs.open("password", "w")
  237.                         file.write(enterd)
  238.                         file.close()
  239.                         break
  240.                     end
  241.                 end
  242.  
  243.             elseif number == 2 then
  244.                 shell.openTab("pastebin run Syw7kVuu")
  245.             elseif number == 3 then
  246.                 shell.openTab("lua")
  247.             elseif number == 4 then
  248.                 shell.run("rom/programs/pocket/falling.lua")
  249.             elseif number == 5 then
  250.                 term.setBackgroundColor(colors.black)
  251.                 shell.run("rom/programs/fun/worm.lua")
  252.             end
  253.  
  254.         end
  255.        
  256.     elseif event[1] == "key" then   -- let's you exit the program
  257.         if event[2] == keys.delete then
  258.             term.setBackgroundColor(colors.black)
  259.             term.setCursorPos(1, 1)
  260.             term.clear()
  261.             break
  262.         end
  263.     end
  264.  
  265.  
  266. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement