Advertisement
TwiXon4ik

Untitled

Oct 9th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.42 KB | None | 0 0
  1. --|============================|
  2. --| SkyPad. |
  3. --| Автор: SkyDrive_ |
  4. --| Проект McSkill, cервер HTC |
  5. --| 14.05.2017 |
  6. --| Version: 1.2 by Niker323 |
  7. --|============================|
  8. local component = require("component")
  9. local computer=require("computer")
  10. local event = require("event")
  11. local term = require("term")
  12. local shell = require("shell")
  13. local fs = require("filesystem")
  14. local unicode=require("unicode")
  15. local serial = require("serialization")
  16.  
  17. if not fs.exists("/lib/Sky.lua") then
  18. shell.execute("wget https://www.dropbox.com/s/ct5zsbm81zir7w2/Sky%28lib%29.lua?dl=1 /lib/Sky.lua")
  19. end
  20. local Sky = require("Sky")
  21. local g = component.gpu
  22. event.shouldInterrupt = function () return false end
  23. --------------------Настройки--------------------
  24. local WIGHT, HEIGHT = 146, 42 --Разрешение моника 146/112 x 42
  25. local PASS = "123" --Пасс
  26. local COLOR1 = 0x00ffff --Рамка
  27. local COLOR2 = 0x0000ff --Цвет кнопок
  28. local COLOR3 = 0x333333 --Таблица
  29. local COLOR_SHELL = 0xff00ff --Цвет шелла
  30. -------------------------------------------------
  31. if not (fs.exists(shell.getWorkingDirectory() .. "/Settings.lua")) then
  32. shell.execute("wget https://www.dropbox.com/s/jdnw53diy1clu80/Settings.lua?dl=1")
  33. end
  34. if not (fs.exists(shell.getWorkingDirectory() .. "/Programms.lua")) then
  35. shell.execute("wget https://www.dropbox.com/s/12hila3pi3mr3em/Programms.lua?dl=1")
  36. end
  37. if not (fs.exists("/autorun.lua")) then
  38. print("\nНастройка автозапуска...")
  39. file = io.open("/autorun.lua", "w")
  40. file:write("local shell = require('shell')\nlocal term = require('term')\nos.sleep(0.5)\nterm.clear()\nlocal dir = '" .. shell.getWorkingDirectory() .. "'\nif dir ~= '/' then shell.setWorkingDirectory(dir) end\nshell.execute('SkyPad')")
  41. file:close()
  42. os.sleep(1)
  43. end
  44. print("\nИнициализация...")
  45. os.sleep(2)
  46. print("Запуск программы...")
  47. os.sleep(2)
  48.  
  49. local mid = (WIGHT-32)/2+32
  50. local login, prog, tech = false, false, false
  51. local sel = 0
  52.  
  53. WIGHT, HEIGHT = Sky.Resolution(WIGHT, HEIGHT)
  54. Sky.Ram("SkyPad", COLOR1,COLOR2,WIGHT, HEIGHT)
  55.  
  56. file = io.open(shell.getWorkingDirectory() .. "/Programms.lua", "r")
  57. local progs = serial.unserialize("{" .. file:read(9999999) .. "}")
  58. file:close()
  59.  
  60. function Login()
  61. login = false
  62. prog = false
  63. tech = false
  64. Sky.ClearL(HEIGHT)
  65. Sky.ClearR(WIGHT,HEIGHT)
  66. Rules()
  67. g.setForeground(COLOR1)
  68. Sky.Word(mid - 28,7, "MCSKILL", 0x222222)
  69. --users={computer.users()}
  70. --for i=1, #users do
  71. -- computer.removeUser(users[i])
  72. --end
  73. Sky.MidR(WIGHT,32,"Введите пароль:")
  74. term.setCursor(mid-2,33)
  75. local p, nick = Sky.Read({mask = "*", max = 8, accept = "0-9a-f", blink = true, center = true, nick = true})
  76. if p == PASS then
  77. if (nick == "Niker323") then
  78. login = true
  79. Sky.MidR(WIGHT,33,"Приветствую, " .. nick)
  80. computer.addUser(nick)
  81. os.sleep(2)
  82. Sky.ClearL(HEIGHT)
  83. Sky.ClearR(WIGHT,HEIGHT)
  84. Rules(nick)
  85. Table()
  86. else
  87. Sky.MidR(WIGHT,34,"Даже, зная пароль, просто так")
  88. Sky.MidR(WIGHT,35,"ты сюда не войдёшь")
  89. os.sleep(2)
  90. Sky.MidR(WIGHT,37,"Петушинная морда")
  91. os.sleep(3)
  92. Login()
  93. end
  94. end
  95.  
  96. function Rules(nick)
  97. if (login) then
  98. g.setForeground(COLOR2)
  99. Sky.MidL(WIGHT,5,"==========================")
  100. Sky.MidL(WIGHT,11,"==========================")
  101. Sky.MidL(WIGHT,15,"==========================")
  102. Sky.MidL(WIGHT,31,"Добро пожаловать")
  103. g.setForeground(COLOR1)
  104. Sky.MidL(WIGHT,3, "Общая инфа:")
  105. Sky.MidL(WIGHT,6, "Монитор в идеале 5х3")
  106. Sky.MidL(WIGHT,7, "блока, чтоб не париться.")
  107. Sky.MidL(WIGHT,8, "Но если над другой, то")
  108. Sky.MidL(WIGHT,9, "в настройках каждой проги")
  109. Sky.MidL(WIGHT,10, "меняйте параметр WIGHT")
  110. Sky.MidL(WIGHT,12, "Autorun ставится свой,")
  111. Sky.MidL(WIGHT,13, "но его можно")
  112. Sky.MidL(WIGHT,14, "редачить под себя")
  113. Sky.MidL(WIGHT,32,nick)
  114. Sky.Button(7,34,18,3,COLOR1,COLOR2,"Обновить")
  115. Sky.Button(7,37,18,3,COLOR1,COLOR2,"Выйти")
  116. end
  117. end
  118.  
  119. function TechPanel()
  120. prog = false
  121. g.fill(mid - 43, 13, 83, 23, " ")
  122. Sky.MidR(WIGHT, 20, "&bВаще хз, чё тут запилить,")
  123. Sky.MidR(WIGHT, 21, "&bесли есть идеи, напишите :)")
  124. tech = true
  125. end
  126.  
  127. function ProgrammPanel()
  128. g.fill(mid - 43, 13, 83, 23, " ")
  129. tech = false
  130. Sky.MidR(WIGHT,13,"&bСписок программ для OpenComputers&r")
  131. g.setForeground(COLOR3)
  132. Sky.MidR(WIGHT,14, "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━┓")
  133. Sky.MidR(WIGHT,15, "┃ &bНазвание&r ┃ &bСтатус&r ┃ &bРазмер&r ┃")
  134. Sky.MidR(WIGHT,16, "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━╋━━━━━━━━━━┫")
  135. for i = 1, 9 do
  136. Sky.MidR(WIGHT,i+16, "┃ ┃ ┃ ┃")
  137. end
  138. Sky.MidR(WIGHT,26, "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━┻━━━━━━━━━━┛")
  139. DrawProgs(0)
  140. prog = true
  141. end
  142.  
  143. function DrawProgs(s)
  144. sel = s
  145. for i = 1, #progs do
  146. g.setForeground(COLOR1)
  147. g.set(mid-42, i+16, " ")
  148. g.set(mid+29, i+16, " ")
  149. local name_progs = tostring(progs[i][1][1]) .. tostring(progs[i][1][2])
  150. if sel ~= i then
  151. g.set(mid-15-unicode.len(name_progs)/2, i+16, name_progs)
  152. else
  153. g.set(mid-19-unicode.len(name_progs)/2, i+16, ">>> " .. name_progs .. " <<<")
  154. end
  155. if (fs.exists(shell.getWorkingDirectory() .. "/" .. progs[i][1][1] .. ".lua")) then
  156. Sky.Text(mid + 12, i+16, "&2 Установлено &r")
  157. local size = fs.size(shell.getWorkingDirectory() .. "/" .. progs[i][1][1] .. ".lua")
  158. Sky.Text(mid + 33 - unicode.len(size)/2, i+16, size .. "B")
  159. else
  160. Sky.Text(mid + 12, i+16, "&8Не установлено&r")
  161. end
  162. end
  163. g.fill(mid - 42, 27, 84, 10, " ")
  164. if sel ~= 0 then
  165. if (fs.exists(shell.getWorkingDirectory() .. "/" .. progs[sel][1][1] .. ".lua")) then
  166. Sky.Button(mid-21,33,20,3,COLOR1,COLOR2,"Запустить")
  167. Sky.Button(mid+1,33,20,3,COLOR1,COLOR2," Обновить ")
  168. else
  169. Sky.Button(mid-10,33,20,3,COLOR1,COLOR2,"Установить")
  170. end
  171. g.setForeground(COLOR1)
  172. Sky.MidR(WIGHT,28,"Требуемые компоненты:")
  173. local comp = ""
  174. for i = 1, #progs[sel][3] do
  175. comp = comp .. progs[sel][3][i] .. " &0|&r "
  176. end
  177. Sky.MidR(WIGHT,29, "&0|&r " .. comp)
  178. end
  179. end
  180.  
  181. function Click(w,h)
  182. g.setForeground(COLOR1)
  183. if sel ~= 0 then
  184. if (fs.exists(shell.getWorkingDirectory() .. "/" .. progs[sel][1][1] .. ".lua")) then
  185. if w>=mid-21 and w<=mid-2 and h>=33 and h<=35 then
  186. for i = 1, #progs[sel][3] do
  187. if not (component.isAvailable(progs[sel][3][i])) then
  188. Sky.MidR(WIGHT,31,"&6Отсутствует компонент: &4" .. progs[sel][3][i])
  189. os.sleep(3)
  190. DrawProgs(sel)
  191. return
  192. end
  193. end
  194. term.clear()
  195. shell.execute(progs[sel][1][1])
  196. g.setForeground(COLOR1)
  197. print("\nКликни на монитор для перезагрузки")
  198. local e = event.pull("touch")
  199. print("\nРестарт...")
  200. os.sleep(2)
  201. shell.execute("reboot")
  202. elseif w>=mid+1 and w<=mid+20 and h>=33 and h<=35 then
  203. fs.remove(shell.getWorkingDirectory() .. "/" .. progs[sel][1][1] .. ".lua")
  204. Sky.Get(progs[sel][2],progs[sel][1][1] .. ".lua",mid-19,31)
  205. Sky.MidR(WIGHT,31," ")
  206. DrawProgs(sel)
  207. return
  208. end
  209. else
  210. if w>=mid-10 and w<=mid+9 and h>=33 and h<=35 then
  211. Sky.Get(progs[sel][2],progs[sel][1][1] .. ".lua",mid-19,31)
  212. Sky.MidR(WIGHT,31," ")
  213. DrawProgs(sel)
  214. return
  215. end
  216. end
  217. end
  218. for i = 1, #progs do
  219. if w>=mid-42 and w<=mid+38 and h == i + 16 then
  220. DrawProgs(i)
  221. return
  222. end
  223. end
  224. DrawProgs(0)
  225. end
  226.  
  227. function Table()
  228. Sky.DrawImage(mid - 28,7, shell.getWorkingDirectory() .. "/LogoSkill.lua")
  229. Sky.Button(mid - 32,37,20,3,COLOR1,COLOR2,"Проги")
  230. Sky.Button(mid - 10,37,20,3,COLOR1,COLOR2,"Войти в шелл")
  231. Sky.Button(mid + 12,37,20,3,COLOR1,COLOR2,"Тех.панель")
  232. Sky.Button(WIGHT-11,3,7,4,COLOR1,COLOR2,"")
  233. Sky.Text(WIGHT-10,4,"&b┌│┐&r")
  234. Sky.Text(WIGHT-10,5,"&b└─┘&r")
  235. end
  236.  
  237. function getButtons(w,h)
  238. if w>=7 and w<= 25 and h>=34 and h<=36 then --Кнопка обновить
  239. term.clear()
  240. fs.remove(shell.getWorkingDirectory() .. "/SkyPad.lua")
  241. fs.remove(shell.getWorkingDirectory() .. "/Programms.lua")
  242. fs.remove("/lib/Sky.lua")
  243. g.setForeground(COLOR1)
  244. shell.execute("wget https://www.dropbox.com/s/6qsqiexodjvugsi/SkyPad.lua?dl=1 SkyPad.lua")
  245. shell.execute("wget https://www.dropbox.com/s/12hila3pi3mr3em/Programms.lua?dl=1")
  246. shell.execute("wget https://www.dropbox.com/s/ct5zsbm81zir7w2/Sky%28lib%29.lua?dl=1 /lib/Sky.lua")
  247. print("\nРестарт...")
  248. os.sleep(2)
  249. shell.execute("reboot")
  250. elseif w>=7 and w<= 25 and h>=37 and h<=39 then --Кнопка Логин
  251. Login()
  252. elseif w>=mid-32 and w<= mid-13 and h>=37 and h<=39 then --Кнопка Проги
  253. ProgrammPanel()
  254. elseif w>=mid-10 and w<= mid+9 and h>=37 and h<=39 then --Кнопка Войти в шелл
  255. term.clear()
  256. g.setForeground(COLOR_SHELL)
  257. shell.execute("sh")
  258. elseif w>=mid+12 and w<= mid+31 and h>=37 and h<=39 then --Кнопка Тех.Панель
  259. TechPanel()
  260. elseif w>=WIGHT-11 and w<= WIGHT-6 and h>=3 and h<=6 then --Кнопка Офф
  261. computer.shutdown()
  262. end
  263. end
  264.  
  265. Login()
  266.  
  267. while true do
  268. local e,_,w,h,_,nick = event.pull("touch")
  269. if (login) then
  270. getButtons(w,h)
  271. if (prog) then
  272. Click(w,h)
  273. end
  274. end
  275. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement