Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- term.setCursorPos(1,1)
- term.write("Would you like to download the code or the updater? \n code or up")
- local mode = term.read()
- term.clear()
- term.setCursorPos(1,1)
- term.write("Which program would you like to use? \n Farm \n Quarry \n Furnace \n")
- local program = term.read()
- term.clear()
- term.setCursorPos(1,1)
- if mode == "code" then
- local FILENAME = '/'..program..'.lua'
- local cacheBreak = tostring(math.random(0, 99999))
- if program == "farm" then
- res, err = http.get('https://gist.githubusercontent.com/posLop/88141bcd6989689d5eb12d33287bc287/raw/carrot.lua?breaker=' .. cacheBreak)
- elseif program == "quarry" then
- res, err = http.get('https://gist.githubusercontent.com/posLop/5902d8ff5154abeef01221faae3f061e/raw/quarry.lua?breaker=' .. cacheBreak)
- elseif program == "furnace" then
- res, err = http.get('https://gist.githubusercontent.com/posLop/79a81458ae396e5c3b464a01349df60f/raw/funnel.lua?breaker=' .. cacheBreak)
- else
- term.write("invalid name")
- return
- end
- if not res then error(err) end
- local code = res.readAll()
- if not(fs.exists(FILENAME))
- then
- local newHarvest = fs.open(FILENAME, 'w')
- newHarvest.close()
- end
- local readFile = fs.open(FILENAME, 'r')
- local oldCode = readFile.readAll()
- readFile.close()
- local file = fs.open(FILENAME, 'w')
- if oldCode == code
- then
- file.write(oldCode)
- print('NO CHANGES MADE - Same Code')
- else
- file.write(code)
- print('WRITING UPDATE')
- byteDiff = string.len(code) - string.len(oldCode)
- if byteDiff >= 0
- then
- print(tostring(math.abs(byteDiff)) .. ' bytes added')
- else
- print(tostring(math.abs(byteDiff)) .. ' bytes removed')
- end
- end
- file.close()
- res.close()
- elseif mode == "up" then
- if program == "quarry" then
- shell.run("pastebin", "get", "RxebTRQQ", "quarryUp")
- elseif program == "farm" then
- shell.run("pastebin", "get", "vPjt5XQ8", "farmUp")
- elseif program == "furnace" then
- shell.run("pastebin", "get", "5s1uvhv4", "furnaceUp")
- else
- term.write("invalid name")
- end
- else
- term.write("invalid name")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement