Advertisement
HangMan23

ExtraUtilits.lua

Jan 28th, 2019
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.73 KB | None | 0 0
  1. ExtraUtilits = {}
  2.  
  3. ExtraUtilits.version = 1.12
  4.  
  5. ------------------------------------------------
  6.  
  7. local io = require("io")
  8. local component = require("component")
  9. local gpu = component.gpu
  10. local term = require("term")
  11. local event = require("event")
  12. local fs = require("filesystem")
  13. local unicode = require("unicode")
  14. local serialization = require("serialization")
  15. local computer = require("computer")
  16. local internet = require("internet")
  17. local shell = require("shell")
  18.  
  19. ------------------------------------------------
  20.  
  21. local function loadModule(name)
  22.  
  23.   local path = "/lib/ExtraUtilitsModules/" .. name .. ".lua"
  24.  
  25.   local func, reason = loadfile(path)
  26.  
  27.   if not func then
  28.  
  29.     local func = function()
  30.  
  31.       local file = io.open("/lib/ExtraErrLogs.txt", "a")
  32.  
  33.       file:write("[" .. computer.uptime() .. "]:" .. name .. ":" .. path .. ":\n" .. reason .. "\n")
  34.  
  35.       file:close()
  36.  
  37.       local text = "Error with loading module:"
  38.       local text2 = "you can see error logs at /lib/ExtraErrLogs.txt."
  39.  
  40.       local length = #text
  41.       if #text2 > length then length = #text2 end
  42.  
  43.       local width, height = length+2, 4
  44.  
  45.       local w, h = gpu.getResolution()
  46.  
  47.       gpu.setBackground(0x323232)
  48.       gpu.setForeground(0xff0000)
  49.  
  50.       gpu.fill(w / 2 - width / 2, h / 2 - height / 2, width, height, " ")
  51.  
  52.       gpu.set(w / 2 - #text/2, h/2-1, text)
  53.       gpu.set(w / 2 - #text2/2, h/2, text2)
  54.  
  55.       event.pull("key_down")
  56.  
  57.     end
  58.  
  59.     return function() ExtraUtilits.screenBackup(func) end
  60.  
  61.   else
  62.  
  63.     return func
  64.  
  65.   end
  66.  
  67. end
  68.  
  69. ------------------------------------------------
  70.  
  71. function ExtraUtilits.getLines(path) -- Устарело
  72.  
  73.   if fs.exists(path) and not fs.isDirectory(path) then
  74.  
  75.     local lines = 0
  76.     local file = io.open(path, "r")
  77.  
  78.     local i = 0
  79.  
  80.     repeat
  81.  
  82.       local line = file:read()
  83.  
  84.       i = i + 1
  85.  
  86.     until line == nil
  87.  
  88.     return i - 1
  89.  
  90.   elseif not fs.exists(path) then
  91.  
  92.     return nil, "File does not exists"
  93.  
  94.   elseif fs.isDirectory(path) then
  95.  
  96.     return nil, "File is directory"
  97.  
  98.   end
  99.  
  100. end  
  101.  
  102. function ExtraUtilits.progressBar(x, y, whide, progress, total, Bcolor, Fcolor)
  103.  
  104.   local color = gpu.getBackground()
  105.  
  106.   gpu.setBackground(Bcolor)
  107.   gpu.fill(x, y, x + whide, 1, " ")
  108.  
  109.   gpu.setBackground(Fcolor)
  110.   gpu.fill(x, y, x + whide / total * progress, 1, "a")
  111.  
  112.   gpu.setBackground(color)
  113.  
  114. end
  115.  
  116. function ExtraUtilits.screenBackup(...)
  117.  
  118.   local func = table.unpack({...})
  119.  
  120. local gpu = require("component").gpu
  121.  
  122. local w, h = gpu.getResolution()
  123.  
  124. local scr = {}
  125.  
  126. for i = 1, w do
  127.  
  128.   scr[i] = {}
  129.  
  130.   for j = 1, h do
  131.  
  132.     scr[i][j] = {gpu.get(i, j)}
  133.  
  134.   end
  135.  
  136. end
  137.  
  138. func()
  139.  
  140. for i = 1, w do
  141.  
  142.   for j = 1, h do
  143.  
  144.     local symbol = {gpu.get(i, j)}
  145.  
  146.     if symbol[1] ~= scr[i][j][1] or symbol[2] ~= scr[i][j][2] or symbol[3] ~= scr[i][j][3] then
  147.  
  148.       if gpu.getBackground ~= scr[i][j][3] then gpu.setBackground(scr[i][j][3]) end
  149.       if gpu.getForeground ~= scr[i][j][2] then gpu.setForeground(scr[i][j][2]) end
  150.  
  151.       gpu.set(i, j, scr[i][j][1])
  152.  
  153.     end
  154.  
  155.   end
  156.  
  157. end
  158.  
  159. end
  160.  
  161. function ExtraUtilits.buttonPress(...)
  162.  
  163.   local args = {...}
  164.  
  165.   local close = false
  166.  
  167.   while not close do
  168.  
  169.     local ev = {computer.pullSignal()}
  170.  
  171.     local _, _, x, y, key = table.unpack(ev)
  172.  
  173.     if ev[1] == "touch" or ev[1] == "drag" then
  174.  
  175.       for i = 1, #args do
  176.    
  177.         local mas = args[i]
  178.         if mas.close == true then close = true end
  179.  
  180.       end
  181.    
  182.       if x ~= nil and y ~= nil then
  183.  
  184.         for i = 1, #args do
  185.  
  186.           local mas = args[i]
  187.    
  188.           for j = 1, #mas do
  189.  
  190.             if type(mas[i]) == "table" then
  191.  
  192.               if x >= mas[j][1] and x <= mas[j][1] + mas[j][3] - 1 and y >= mas[j][2] and y <= mas[j][2] + mas[j][4] - 1 and mas[j][9] ~= false then
  193.          
  194.                 if key == 0 or mas[j][10] == nil then
  195.  
  196.                   mas[j][8]()
  197.  
  198.                 else if key == 1 then
  199.  
  200.                    mas[j][10]() end
  201.  
  202.                 end
  203.  
  204.                 os.sleep(0.05)
  205.            
  206.               end
  207.  
  208.             end
  209.  
  210.           end
  211.  
  212.         end
  213.  
  214.       end
  215.  
  216.     end
  217.  
  218.     for i = 1, #args do
  219.  
  220.       if args[i].close then close = true end
  221.       if args[i].eventFunc and ev then args[i].eventFunc(ev) end
  222.  
  223.     end
  224.  
  225.   end
  226.  
  227. end
  228.  
  229. function ExtraUtilits.draw(mas)
  230.  
  231.   for i = 1, #mas do
  232.  
  233.     if mas[i][9] ~= false then
  234.  
  235.       local posX = mas[i][1] + mas[i][3] / 2 - unicode.wlen(mas[i][7]) / 2
  236.       local posY = mas[i][2] + mas[i][4] / 2
  237.  
  238.       gpu.setBackground(mas[i][5])
  239.       gpu.setForeground(mas[i][6])
  240.       gpu.fill(mas[i][1], mas[i][2], mas[i][3], mas[i][4], " ")
  241.       gpu.set(posX, posY, mas[i][7])
  242.  
  243.    end
  244.  
  245.   end
  246.  
  247. end
  248.  
  249. function ExtraUtilits.save(var, path)
  250.  
  251.   local tp = type(var)
  252.  
  253.   if tp == "table" then
  254.  
  255.     local file = io.open(path, "w")
  256.  
  257.     file:write("--TABLE--\n" .. serialization.serialize(var))
  258.  
  259.     file:close()
  260.  
  261.   else
  262.  
  263.     local file = io.open(path, "w")
  264.  
  265.     file:write("--" .. unicode.upper(type(var)) .. "--\n" .. tostring(var))
  266.  
  267.     file:close()
  268.  
  269.   end
  270.  
  271. end
  272.  
  273. function ExtraUtilits.load(path)
  274.  
  275.   if not fs.exists then return nil, "File does not exists" end
  276.  
  277.   local file = io.open(path, "r")
  278.  
  279.   local tp = unicode.lower(string.sub(file:read(), 3, -3))
  280.  
  281.   if tp == "table" then
  282.  
  283.     return serialization.unserialize(file:read())
  284.  
  285.   elseif tp == "number" then
  286.  
  287.     return tonumber(file:read())
  288.  
  289.   else
  290.  
  291.     return file:read()
  292.  
  293.   end
  294.  
  295. end
  296.  
  297.  
  298.  
  299. function ExtraUtilits.list(path)
  300.  
  301.   local list = fs.list(path)
  302.  
  303.   tbl = {}
  304.  
  305.   i = 1
  306.   w = false
  307.   while not w do
  308.    
  309.     local n = list()
  310.  
  311.     if n then
  312.      
  313.       tbl[i] = n
  314.       i = i + 1
  315.  
  316.     else
  317.  
  318.       w = true
  319.  
  320.     end
  321.  
  322.   end
  323.  
  324.   return tbl
  325.  
  326. end
  327.  
  328. function ExtraUtilits.disintegrate(text)  
  329.  
  330.   local massive = {}
  331.  
  332.   for i = 1, unicode.wlen(text) do
  333.  
  334.     massive[i] = tonumber(unicode.sub(text, i, -(unicode.wlen(text) - i + 1)))
  335.  
  336.   end return table.unpack(massive)
  337.  
  338. end
  339.  
  340.  
  341.  
  342. function ExtraUtilits.stringToTable(str)
  343.  
  344.   local tbl = {}
  345.  
  346.   for i = 1, unicode.wlen(str) do
  347.  
  348.     tbl[i] = string.sub(str, i, i)
  349.  
  350.   end
  351.  
  352.   return tbl
  353.  
  354. end
  355.  
  356. function ExtraUtilits.replace(str, list)
  357.  
  358.   local tbl = ExtraUtilits.stringToTable(str)
  359.   local replaced = ""
  360.  
  361.   for index = 1, #tbl do
  362.  
  363.     local symbol = nil
  364.  
  365.     for from in pairs(list) do
  366.  
  367.       if from == tbl[index] then
  368.  
  369.         symbol = list[from]
  370.  
  371.       end
  372.  
  373.     end
  374.  
  375.     if not symbol then
  376.  
  377.       symbol = tbl[index]
  378.  
  379.     end
  380.  
  381.     replaced = replaced .. symbol
  382.  
  383.   end
  384.  
  385.   return replaced
  386.  
  387. end
  388.  
  389.  
  390.  
  391. function ExtraUtilits.getFormat(str)
  392.  
  393.   local tbl = ExtraUtilits.stringToTable(str)
  394.   local format
  395.  
  396.   for i = 1, string.len(str) do
  397.  
  398.     if tbl[i] == "." then format = string.sub(str, -(string.len(str)-i)) end
  399.  
  400.   end
  401.  
  402.   return format
  403.  
  404. end
  405.  
  406. function ExtraUtilits.getLine(path, num)
  407.  
  408.   if fs.exists(path) and not fs.isDirectory(path) and ExtraUtilits.getLines(path) >= num then
  409.  
  410.     local file = io.open(path, "r")
  411.     local line
  412.  
  413.     for i = 1, num do
  414.  
  415.       if i == num then line = file:read() else file:read() end
  416.  
  417.     end
  418.  
  419.     file:close()
  420.     return line
  421.  
  422.   elseif not fs.exists(path) then return nil, "File does not exists."
  423.  
  424.   elseif fs.isDirectory(path) then return nil, "File is directory."
  425.  
  426.   end
  427.  
  428. end
  429. ------------------------------------------------
  430.  
  431. ExtraUtilits.ReadyUtilits = {}
  432.  
  433. function ExtraUtilits.ReadyUtilits.WriteFieldUI(...)
  434.  
  435.   local text = ""
  436.  
  437.   local args = {...}
  438.  
  439.   local function forBackup()
  440.  
  441.     local x = args[1]
  442.     local y = args[2]
  443.     local txt = args[3]
  444.  
  445.     if #args == 3 then
  446.  
  447.       tColor = 0xffffff
  448.       bColor = 0x161616
  449.       sColor = 0x161616
  450.       cColor = 0x323232
  451.       fColor = 0x00ff00
  452.       fOkColor = 0x00ff00
  453.       bOkColor = 0xffffff
  454.  
  455.     elseif #args == 10 then
  456.  
  457.       fColor = args[4]
  458.       bColor = args[5]
  459.       sColor = args[6]
  460.       cColor = args[7]
  461.       tColor = args[8]
  462.       fOkColor = args[9]
  463.       bOkColor = args[10]
  464.  
  465.     else
  466.  
  467.       print("args: pos x, pos y, message text, write color, write field background color, window background color, cursor color, mes color, OK button foreground, OK button background.")
  468.       os.exit()
  469.  
  470.     end
  471.  
  472.     local time = computer.uptime()
  473.  
  474.     gpu.setBackground(sColor)
  475.     gpu.setForeground(tColor)
  476.  
  477.     gpu.fill(x, y, 40, 3, " ")
  478.  
  479.     gpu.setBackground(sColor)
  480.     gpu.setForeground(tColor)
  481.    
  482.     gpu.fill(x + 1, y + 1, 38, 1, " ")
  483.     gpu.set(x, y, txt)
  484.  
  485.     local w = false
  486.  
  487.     gpu.setForeground(fOkColor)
  488.     gpu.setBackground(bOkColor)
  489.  
  490.     gpu.fill(x + 35, y + 2, 4, 1, " ")
  491.     gpu.set(x + 35, y + 2, "OK")
  492.  
  493.     gpu.setBackground(bColor)
  494.     gpu.setForeground(fColor)
  495.  
  496.     gpu.fill(x + 1, y + 1, 38, 1, " ")
  497.  
  498.     while not w do
  499.  
  500.       local type, _, key, eY = event.pull(0)
  501.  
  502.       if type == "key_down" then
  503.  
  504.         time = computer.uptime()
  505.  
  506.         if key >= 33 and key <= 125 or key >= 97 and key <= 122 or key >= 1040 and key <= 1071 or key <= 1103 and key >= 1072 or key == 32 then
  507.  
  508.           if unicode.wlen(text) < 38 then
  509.  
  510.             text = text .. unicode.char(key)
  511.             gpu.setForeground(fColor)
  512.             gpu.setBackground(bColor)
  513.             gpu.set(x + 1, y + 1, text)
  514.        
  515.           end
  516.  
  517.         elseif key == 13 then
  518.  
  519.           os.sleep(0.0000010) w = true
  520.  
  521.         elseif key == 8 then
  522.  
  523.           text = string.sub(text, 1, unicode.wlen(text) - 1)
  524.           gpu.fill(x + 1, y + 1, 38, 1, " ")
  525.           gpu.set(x + 1, y + 1, text)
  526.  
  527.         elseif key == 9 then
  528.  
  529.           w = true
  530.           n = false
  531.  
  532.         end
  533.  
  534.       elseif type == "touch" or type == "drag" then
  535.  
  536.         if key >= x + 35 and key <= x + 39 and eY == y + 2 then
  537.  
  538.           w = true
  539.  
  540.         end
  541.  
  542.       end
  543.  
  544.       if computer.uptime() - time == 1 then
  545.  
  546.         time = computer.uptime()
  547.  
  548.         if unicode.wlen(text) <= 37 then
  549.          
  550.           gpu.setForeground(cColor)
  551.  
  552.           if gpu.get(x + 1 + unicode.wlen(text), y + 1) == " " then
  553.  
  554.             gpu.set(x + 1 + unicode.wlen(text), y + 1, "∣")
  555.  
  556.           else
  557.  
  558.             gpu.set(x + 1 + unicode.wlen(text), y + 1, " ")
  559.  
  560.           end
  561.      
  562.         gpu.setForeground(fColor)
  563.  
  564.         end
  565.  
  566.       end
  567.  
  568.     end
  569.  
  570.   end
  571.  
  572.   ExtraUtilits.screenBackup(forBackup, 200)
  573.  
  574.   return text
  575.  
  576. end
  577.  
  578.  
  579.  
  580. function ExtraUtilits.ReadyUtilits.RGBPalette(x, y, text, color)
  581.  
  582.   os.sleep(0.05)
  583.  
  584.   local symbols = {
  585.   unicode.char(9654),
  586.   unicode.char(9664)
  587.   }
  588.  
  589.   local r, g, b = 0, 0, 0
  590.  
  591.   if color then r, g, b = ExtraUtilits.Color.Extract(color) end
  592.  
  593.   local function main()
  594.  
  595.     gpu.setBackground(0x161616)
  596.     gpu.fill(x, y, 15, 5, " ")
  597.    
  598.     if text then
  599.    
  600.       gpu.setForeground(0x00ffff)
  601.       gpu.set(x, y, text)
  602.  
  603.     end
  604.  
  605.     local ui = function() end
  606.  
  607.     local color = ExtraUtilits.Color.Pack(r, g, b)
  608.  
  609.     function setR()
  610.  
  611.       repeat
  612.  
  613.         r = tonumber(ExtraUtilits.ReadyUtilits.WriteFieldUI(60, 23, "Enter count of red color:"))
  614.  
  615.         if r then ui() end
  616.  
  617.       until r and r>=0 and r<=255
  618.  
  619.     end
  620.  
  621.     function setB()
  622.  
  623.       repeat
  624.  
  625.         b = tonumber(ExtraUtilits.ReadyUtilits.WriteFieldUI(60, 23, "Enter count of blue color:"))
  626.  
  627.         if b then ui() end
  628.  
  629.       until b and b>=0 and b<=255
  630.  
  631.     end
  632.  
  633.     function setG()
  634.  
  635.       repeat
  636.  
  637.         g = tonumber(ExtraUtilits.ReadyUtilits.WriteFieldUI(60, 23, "Enter count of green color:"))
  638.  
  639.         if g then ui() end
  640.  
  641.       until g and g>=0 and g<=255
  642.  
  643.     end
  644.  
  645.     local buttons = {
  646.     {x+8, y+1, 1, 1, 0x161616, 0x00ffff, symbols[2], function() if r - 5 >= 0 then r = r - 5 ui() end end},
  647.     {x+8, y+2, 1, 1, 0x161616, 0x00ffff, symbols[2], function() if g - 5 >= 0 then g = g - 5 ui() end end},
  648.     {x+8, y+3, 1, 1, 0x161616, 0x00ffff, symbols[2], function() if b - 5 >= 0 then b = b - 5 ui() end end},
  649.     {x+12, y+1, 1, 1, 0x161616, 0x00ffff, symbols[1], function() if r + 5 <= 255 then r = r + 5 ui() end end},
  650.     {x+12, y+2, 1, 1, 0x161616, 0x00ffff, symbols[1], function() if g + 5 <= 255 then g = g + 5 ui() end end},
  651.     {x+12, y+3, 1, 1, 0x161616, 0x00ffff, symbols[1], function() if b + 5 <= 255 then b = b + 5 ui() end end},
  652.     {x+9, y+1, 3, 1, 0x161616, 0xff0000, tostring(r), setR},
  653.     {x+9, y+2, 3, 1, 0x161616, 0x00ff00, tostring(g), setG},
  654.     {x+9, y+3, 3, 1, 0x161616, 0x0000ff, tostring(b), setB}
  655.     }
  656.  
  657.     function ui()
  658.  
  659.       color = ExtraUtilits.Color.Pack(r, g, b)
  660.  
  661.       gpu.setBackground(color)
  662.       gpu.fill(x+2, y+1, 4, 3, " ")
  663.       ExtraUtilits.draw(buttons)
  664.  
  665.       buttons[7][7] = tostring(r)
  666.       buttons[8][7] = tostring(g)
  667.       buttons[9][7] = tostring(b)
  668.  
  669.       ExtraUtilits.draw(buttons)
  670.  
  671.     end
  672.  
  673.     buttons.eventFunc = function(ev)
  674.  
  675.       if ev[3] == 13 and ev[1] == "key_down" then
  676.      
  677.         buttons.close = true
  678.  
  679.       elseif ev[1] == "scroll" and ev[3] <= x + 12 and ev[3] >= x + 9 then
  680.  
  681.         if ev[5] == 1 then
  682.    
  683.           if ev[4] == y+1 and r + 3 <= 255 then r = r + 3 end
  684.           if ev[4] == y+2 and g + 3 <= 255 then g = g + 3 end
  685.           if ev[4] == y+3 and b + 3 <= 255 then b = b + 3 end
  686.  
  687.         else
  688.  
  689.           if ev[4] == y+1 and r - 3 >= 0 then r = r - 3 end
  690.           if ev[4] == y+2 and g - 3 >= 0 then g = g - 3 end
  691.           if ev[4] == y+3 and b - 3 >= 0 then b = b - 3 end
  692.  
  693.         end  
  694.  
  695.         ui()    
  696.  
  697.       end
  698.  
  699.     end
  700.  
  701.     ui()
  702.     ExtraUtilits.buttonPress(buttons)
  703.  
  704.   end
  705.  
  706.   ExtraUtilits.screenBackup(main)
  707.  
  708.   return ExtraUtilits.Color.Pack(r, g, b)
  709.  
  710. end
  711.  
  712. function ExtraUtilits.ReadyUtilits.WFUIV2(...)
  713.  
  714.   return loadModule("WriteFieldUIv2")(...)
  715.  
  716. end
  717.  
  718. ------------------------------------------------
  719.  
  720. ExtraUtilits.Color = {}
  721.  
  722. function ExtraUtilits.Color.Extract(color)
  723.  
  724.   color = color % 0x1000000  
  725.  
  726.   local r = math.floor(color / 0x10000)  
  727.   local g = math.floor((color - r * 0x10000) / 0x100)
  728.   local b = color - r * 0x10000 - g * 0x100
  729.  
  730.   return r, g, b
  731.  
  732. end
  733.  
  734. function ExtraUtilits.Color.Pack(r, g, b)
  735.  
  736.   if r>=0 and r<=255 and g>=0 and g<=255 and b>=0 and g<=255 then return (r *(256^2)) + (g * 256) + b end
  737.  
  738. end
  739.  
  740. function ExtraUtilits.Color.Invert(color)
  741.  
  742.   local r, g, b = ExtraUtilits.Color.Extract(color)
  743.   return ExtraUtilits.Color.Pack(255 - r, 255 - g, 255 - b)
  744.  
  745. end
  746.  
  747. function ExtraUtilits.Color.Add(color, value)
  748.  
  749.   local r, g, b = ExtraUtilits.Color.Extract(color)
  750.  
  751.   if r + value > 255 then r = 255 elseif r + value < 0 then r = 0 else r = r - value end
  752.   if g + value > 255 then g = 255 elseif g + value < 0 then g = 0 else g = g - value end
  753.   if b + value > 255 then b = 255 elseif b + value < 0 then b = 0 else b = b - value end
  754.  
  755. end
  756.  
  757. function ExtraUtilits.Color.hideScreen(func, value)
  758.  
  759.   local function main()
  760.  
  761.     local w, h = gpu.getResolution()
  762.  
  763.     for i = 1, w do
  764.  
  765.       for j = 1, h do
  766.  
  767.         local symbol, foreground, background = gpu.get(i, j)
  768.  
  769.         local fr, fg, fb = ExtraUtilits.Color.Extract(foreground)
  770.         local br, bg, bb = ExtraUtilits.Color.Extract(background)
  771.  
  772.         if fr - value >= 0 then fr = fr - value end
  773.         if fg - value >= 0 then fg = fg - value end
  774.         if fb - value >= 0 then fb = fb - value end
  775.  
  776.         if br - value >= 0 then br = br - value end
  777.         if bg - value >= 0 then bg = bg - value end
  778.         if bb - value >= 0 then bb = bb - value end
  779.  
  780.         foreground = ExtraUtilits.Color.Pack(fr, fg, fb)
  781.         background = ExtraUtilits.Color.Pack(br, bg, bb)
  782.  
  783.         if gpu.getForeground ~= foreground then gpu.setForeground(ExtraUtilits.Color.Pack(fr, fg, fb)) end
  784.         if gpu.getBackground ~= background then gpu.setBackground(ExtraUtilits.Color.Pack(br, bg, bb)) end
  785.  
  786.         gpu.set(i, j, symbol)
  787.  
  788.       end
  789.  
  790.     end
  791.  
  792.     func()
  793.  
  794.   end
  795.  
  796.   ExtraUtilits.screenBackup(main)
  797.  
  798. end
  799. ------------------------------------------------
  800.  
  801. ExtraUtilits.internet = {}
  802.  
  803. function ExtraUtilits.internet.get(URL)
  804.  
  805.   local req = internet.request(URL)
  806.   local text = ""
  807.  
  808.   for line in req do
  809.  
  810.     text = text .. line
  811.  
  812.   end
  813.  
  814.   return text
  815.  
  816. end
  817.  
  818. function ExtraUtilits.internet.downloadPaste(paste, path)
  819.  
  820.   local file, reason = io.open(path, "w")
  821.  
  822.   if not file then
  823.  
  824.     error("Failed to opening file for writing: " .. reason)
  825.  
  826.   end
  827.  
  828.   file:write(get("https://pastebin.com/raw/" .. paste))
  829.   file:close()
  830.  
  831. end
  832.  
  833. function ExtraUtilits.internet.download(URL, path)
  834.  
  835.   local file = io.open(path, "w")
  836.   file:write(ExtraUtilits.internet.get(URL))
  837.   file:close()
  838.  
  839. end
  840.  
  841.  
  842.  
  843. ------------------------------------------------
  844.  
  845. return ExtraUtilits
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement