Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --now with autoupdate!----
- ----IMGRAB-------//
- --------------/
- args = {...}
- local function getAPI(api)
- if api == "bigfont" then
- fs.makeDir("apis")
- local pbHandle = http.get("https://pastebin.com/raw/3LfWxRWh")
- local pbContents = pbHandle.readAll()
- local fileHandle = fs.open("/apis/bigfont", "w")
- fileHandle.write(pbContents)
- fileHandle.close()
- end
- end
- if not fs.exists("/apis/bigfont") then
- getAPI("bigfont")
- end
- local function loadAPI(file)
- local env = {}
- setmetatable(env, {__index = _G})
- local fn, err = loadfile(file, nil, env)
- if not fn then error(err) end
- fn()
- local api = {}
- for k, v in pairs(env) do
- if k ~= "_ENV" then
- api[k] = v
- end
- end
- return api
- end
- local function update()
- local fileR = fs.open("imgrab","r")
- local pbHandle = http.get("https://pastebin.com/raw/bvebq8PK")
- local pbContents = pbHandle.readAll()
- if fileR.readAll() ~= pbContents then
- fileR.close()
- fs.delete("imgrab")
- local file = fs.open("imgrab","w")
- file.write(pbContents)
- pbHandle.close()
- file.close()
- end
- end
- update()
- local function useAPI(filename)
- print("Use API?")
- input = read()
- if string.lower(input) == "y" or string.lower(input) == "yes" then
- local api = loadAPI(filename)
- print("Device ID, (term for terminal")
- input = read()
- if input == "term" then
- api.draw(term)
- else
- print("Is this a device with .setTextScale? (monitors, etc)")
- inputQuestion = read()
- if string.lower(inputQuestion) == "yes" or string.lower(inputQuestion) == "y" or string.lower(inputQuestion) == "yea"
- local inputDev = peripheral.wrap(input)
- inputDev.setTextScale(0.5)
- api.draw(peripheral.wrap(input))
- else
- api.draw(peripheral.wrap(input))
- end
- else
- error("Done!")
- end
- end
- if args[1] == "disk" then
- print("Where is your disk located? (directory-wise)")
- input = read()
- local diskMode = input
- end
- print("Enter URL")
- input = read()
- url = "https://tojuroku.switchcraft.pw/?url="..textutils.urlEncode(input)
- urlHandle = http.get(url)
- local function getContents()
- urlContents = urlHandle.readAll()
- end
- print("Save or use from web?")
- input = read()
- if string.lower(input) == "web" or string.lower(input) == "yes" or string.lower(input) == "y" or string.lower(input) == "use" then
- getContents()
- if type(diskMode) == "string" then
- fs.makeDir("/"..diskMode.."/temp")
- fs.makeDir("/"..diskMode.."/temp/imgrab")
- fs.makeDir("/"..diskMode.."/temp/imgrab/XX667700/")
- filename = "/"..diskMode.."/temp/imgrab/XX667700/temp1.lua"
- local file = fs.open(filename, "w")
- file.write(urlContents)
- file.close()
- useAPI(filename)
- fs.delete(filename)
- else
- filename = "/temp/imgrab/XX667700/temp1.lua"
- local file = fs.open(filename, "w")
- file.write(urlContents)
- file.close()
- useAPI(filename)
- fs.delete(filename)
- end
- else
- print("Enter Filename")
- input = read()
- if fs.exists(input) then
- printError("File Exists")
- print("Overwrite?")
- input = read()
- input = filename
- if string.lower(input) == "y" or string.lower(input) == "yes" then
- fs.delete(input)
- else
- error("User said no")
- end
- end
- local file = fs.open(input, "w")
- getContents()
- file.write(urlContents)
- useAPI(filename)
- end
Add Comment
Please, Sign In to add comment