Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not (string.sub(os.version(),1,8)=="TurtleOS") then
- print("Diese API ist nur fuer Turtles gedacht!")
- return
- end
- local startupFile = "turtle.startup"
- local apiFolder = "customAPI"
- local apiFile = "turtle.advanced"
- local apiPath = fs.combine(apiFolder,apiFile)
- local function getFileContent( path )
- local result
- if fs.exists(path) then
- local file = fs.open(path, "r")
- result = file.readAll()
- file.close()
- end
- return result
- end
- -- break if the api file is allready existing
- if fs.exists(apiPath) then
- print("\""..apiPath.."\" existiert")
- print(" schon auf dem System!")
- return
- end
- local oldStartup = getFileContent("startup")
- local newStartup = getFileContent("disk/"..startupFile)
- -- break if defined startup file is not existant
- if not newStartup then
- print("\"disk/"..startupFile.."\" konnte")
- print(" nicht gelesen werden!")
- return
- end
- -- break if api file could not be found
- if not fs.exists("disk/"..apiFile) then
- print("\"disk/"..apiFile.."\" existiert nicht!")
- return
- end
- -- try copying api file
- if not fs.exists(apiFolder) then
- fs.makeDir(apiFolder)
- end
- fs.copy("disk/"..apiFile, apiPath)
- -- check if startup exists on system
- if not oldStartup then
- -- if not, simply copy the startup file
- fs.copy("disk/"..startupFile, "startup")
- else
- -- if it does, merge the new one in at the front
- local file = fs.open("startup", "w")
- file.writeLine("--- LOAD API ---")
- file.writeLine(newStartup)
- file.writeLine()
- file.writeLine("--- BEGIN OF STARTUP ---")
- file.writeLine(oldStartup)
- file.close()
- end
- -- print success message
- textutils.slowPrint("Installation vollstaendig!")
Advertisement
Add Comment
Please, Sign In to add comment