Advertisement
taoshi

pimloader.lua

Jan 20th, 2024 (edited)
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.77 KB | None | 0 0
  1. local inet=require'internet'
  2. local c='component'
  3. local gpu=require(c).gpu
  4. local fs=require(c).filesystem
  5. --local branch='https://raw.githubusercontent.com/Zardar/pimmarket/pimmarket_0.85/'
  6. --local branch="https://raw.githubusercontent.com/Zardar/pimmarket/master/"
  7. local computer=require'computer'
  8. local events={'touch'}
  9. local url,fd,bd='',0x68f029,0x303030
  10. pullSignal=computer.pullSignal 
  11. computer.pullSignal=function(...)
  12.     local e={pullSignal(...)}
  13.     for k in pairs(events)do
  14.         if e[1]==events[k] then
  15.              return scrDr(e[3],e[4])
  16.         end
  17.     end
  18.     return table.unpack(e)
  19. end
  20.  
  21. local b={
  22. s={x=2,xs=21,y=2,ys=3,text='запустить сервер',tx=2,ty=1,bg=bd,fg=fd,f='pimserver.lua'},
  23. c={x=2,xs=21,y=6,ys=3,text='запустить клиент',tx=2,ty=1,bg=bd,fg=fd,f='pimmarket.lua'},
  24. us={x=2,xs=28,y=10,ys=3,text='скачать+запустить сервер',tx=2,ty=1,bg=bd,fg=fd},
  25. uc={x=2,xs=28,y=14,ys=3,text='скачать+запустить клиент',tx=2,ty=1,bg=bd,fg=fd},
  26. ul={x=2,xs=20,y=22,ys=3,text='апгрейд загрузчика',tx=2,ty=1,bg=bd,fg=fd,f='loader.lua'},
  27. up={x=2,xs=31,y=18,ys=3,text='скачать и запустить Ме крафт',tx=2,ty=1,bg=bd,fg=fd,f='pimmeprecraft.lua'}
  28. }
  29. local screen = {'s','c','us','uc'}
  30.  
  31. local function wget(url,name)
  32.     local handle=inet.request(url)
  33.     local result=''
  34.     for chunk in handle do result=result..chunk end
  35.     local file=io.open(name,'w')
  36.     file:write(result)
  37.     file:close()
  38.     file=nil
  39.     handle=nil
  40.     result=nil
  41. end
  42.  
  43. local sa={}
  44. sa.c=function()if fs.exists('/home/'..b.c.f)then return os.execute(b.c.f)end end
  45. sa.s=function()if fs.exists('/home/'..b.s.f)then return os.execute(b.s.f)end end
  46. sa.us=function() url="https://pastebin.com/raw/jGMM1vqD" wget(url,b.s.f)return sa.s()end
  47. sa.uc=function() url="https://pastebin.com/raw/M5anF9JW" wget(url,b.c.f)return sa.c()end
  48. --sa.up=function() url=branch..b.up.f wget(url,b.up.f)return os.execute(b.up.f)end
  49.  
  50. local clear=function()
  51.     local x,y=gpu.getViewport()
  52.     gpu.setBackground(0x111111)
  53.     gpu.fill(1,1,x,y,' ')
  54.     return true
  55. end
  56. local function place(buttons)
  57.     for n in pairs(buttons)do
  58.         local btn=b[buttons[n]]
  59.         gpu.setBackground(btn.bg)
  60.         gpu.fill((btn.x),(btn.y),(btn.xs),(btn.ys),' ')
  61.         gpu.setForeground(btn.fg)
  62.         gpu.set((btn.x)+(btn.tx),(btn.y)+(btn.ty),btn.text)
  63.     end
  64.     return true
  65. end
  66.  
  67. function scrDr(e3,e4)
  68.     local x,y=e3,e4
  69.     for f in pairs (screen) do
  70.         local btn=b[screen[f]]
  71.         local a=(x >= btn.x and x <=(btn.xs+btn.x-1))and(y >=(btn.y)and y <=(btn.ys+btn.y-1))
  72.         if a then
  73.             events={}
  74.             return sa[screen[f]]()
  75.         end
  76.     end
  77.     return false
  78. end
  79.  
  80. local x=gpu.getViewport()
  81. for n in pairs(b)do
  82.     b[n].x = x/2-b[n].xs/2-1
  83. end
  84. wget("https://pastebin.com/raw/H3Mu2wi2"..b.ul.f,b.ul.f)
  85. clear()
  86. place(screen)
  87. return true
  88.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement