Advertisement
Guest User

autorun

a guest
Oct 19th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.47 KB | None | 0 0
  1. ---------------- libs
  2. local c = require("computer")
  3. local co = require("component")
  4. local gpu = co.gpu
  5. local lg = require("linegui")
  6. local term = require("term")
  7. local event = require("event")
  8. local shell = require("shell")
  9. local fs = require("filesystem")
  10. ---------------- variables
  11. local ln,ht = gpu.getResolution()
  12. local colors = {}
  13. local shut = true
  14. ---------------- file infos
  15. if fs.exists("lineOS/colors") then
  16.   cols = io.open("lineOS/colors","r")
  17.   for var in cols:lines() do table.insert(colors, var) end
  18.   cols:close()
  19. else
  20.   cols = io.open("lineOS/colors","w")
  21.   cols:write("0x6060ff\n")
  22.   cols:write("0x4040ff\n")
  23.   cols:write("0x5050ff\n")
  24.   for var in cols:lines() do table.insert(colors,var) end
  25.   cols:close()
  26. end
  27. ---------------- shorts
  28. sc=term.setCursor
  29. wr=term.write
  30. sb=gpu.setBackground
  31. sf=gpu.setForeground
  32. fi=gpu.fill
  33. gre=gpu.getResolution
  34. ---------------- preps
  35. os.sleep(2)
  36. gggg=false
  37. term.clear()
  38. ---------------- functions
  39. function desktop()
  40.   local a=sb(tonumber(colors[1]))
  41.   term.clear()
  42.   sb(tonumber(colors[2]))
  43.   fi(1,ht-1,ln,2," ")
  44.   lg.colortext(2,ht,"Пуск",0xffffff)
  45. end
  46.  
  47. function midday()
  48.   os.execute("/lineOS/midday")
  49.   os.execute("/core")
  50. end
  51.  
  52. function start()
  53.     starteri = true  
  54.     local gasy =  sb(tonumber(colors[3]))
  55.     lg.drawbox(1,ht-12,20,11, tonumber(colors[3]))
  56.     sc(1,ht-12) wr("Выключение")
  57.     sc(1,ht-11) wr("Перезагрузка")
  58.     sc(1,ht-10) wr("Выход в Shell")
  59.     sc(1,ht-9) wr("Файловый менеджер")
  60.   while starteri do
  61.     local typer,_,x,y = event.pull(1)
  62.    if typer=="touch" then
  63.     if x<20 and y==ht-12  then
  64.       starteri=false
  65.       shut=false
  66.       shutdown=true
  67.     elseif x>20 or y<13 then
  68.       starteri=false
  69.       desktop()
  70.     elseif x<20 and y==ht-11 then
  71.       starteri=false
  72.       shut=false
  73.       reboot=true
  74.     elseif x<20 and y==ht-10 then
  75.       starteri=false
  76.       gggg=true
  77.       term.clear()
  78.     elseif x<20 and y==ht-9 then
  79.       term.clear()
  80.       midday()
  81.     end
  82.    end
  83.     sb(gasy)
  84.   end
  85. end
  86.  
  87. ----------------- clicks
  88. function click(_,_,x,y)
  89.   local type,_,x,y = event.pull(1)
  90.   if type == "touch" then
  91.     if x<20 and y>ht-2 then
  92.       start()
  93.     end
  94.   end
  95. end
  96.  
  97. ------------------ main
  98. desktop()
  99. ------------------
  100. while shut==true do
  101.   --os.sleep(1)
  102.   sc(ln-20,ht) wr(os.date())
  103.   click()
  104.   if gggg==true then
  105.     break
  106.   end
  107. end
  108. term.clear()
  109. ------------------
  110. if reboot then c.shutdown(true) end
  111.  
  112. if shutdown then
  113.   c.shutdown()
  114. else
  115.   sb(a)
  116.   term.clear()
  117. end
  118. ------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement