dumpkin

Luam Installation Script

Jan 14th, 2024 (edited)
1,446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.75 KB | Software | 0 0
  1. local a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
  2. local b = {}
  3. for c = 1, #a do
  4.     local d = a:sub(c, c)
  5.     b[d] = c - 1
  6. end; local e, f, g = bit.blshift, bit.blogic_rshift, bit.band; local function h(i)
  7.     assert(#i == 4, "Chars must be of length 4")
  8.     local j = #i:gsub("[^=]", "")
  9.     local k = i:gsub("=", "A")
  10.     local l = 0; local m = {}
  11.     for c = 1, 4 do l = l + e(b[k:sub(c, c)], 24 - c * 6) end; for c = 1, 3 do m[c] = g(f(l, 24 - c * 8), 0xff) end; return
  12.     m, j
  13. end; local function n(o, p)
  14.     assert(#o % 4 == 0, "Coded string should be a multiple of 4")
  15.     local q = fs.open(p, "wb")
  16.     for c = 1, #o, 4 do
  17.         local r, j = h(o:sub(c, c + 3))
  18.         for s = 1, 3 - j do q.write(r[s]) end
  19.     end; q.close()
  20. end; local t = "Git-Monke"
  21. local u = "Luam-CLI"
  22. local v = "release/luam.lua"
  23. local w = string.format("https://api.github.com/repos/%s/%s/contents/%s", t, u, v)
  24. local x = http.get(w)
  25. if x then
  26.     local y = x.readAll()
  27.     x.close()
  28.     local z = textutils.unserializeJSON(y)
  29.     if z and z.content then
  30.         local A = z.content:gsub("%\n", "")
  31.         n(A, "luam.lua")
  32.     else print("Error: Unable to parse GitHub response.") end
  33. else print("Error: Unable to fetch file from GitHub.") end; local B = 'shell.setPath(shell.path() .. ":" .. "/")'
  34. local C = 'shell.setPath%(shell.path%(%) %.. ":" .. "/"%)'
  35. C = C:gsub("([%(%)%.])", "%%%1")
  36. local D = fs.open("startup.lua", "r")
  37. local E = D and D.readAll()
  38. if not E or E and not E:find(C) then
  39.     shell.setPath(shell.path() .. ":" .. "/")
  40.     local q = fs.open("startup.lua", "w")
  41.     q.write("\n" .. B)
  42.     q.close()
  43.     print("Luam has been installed successfully!")
  44.     print("Run 'luam help' for information about usage")
  45. end
Advertisement
Add Comment
Please, Sign In to add comment