BrunoZockt

OCM.updater

Jul 17th, 2016
37,838
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.57 KB | None | 0 0
  1. function save(path, content)
  2.     local file = fs.open(path, "w")
  3.     file.writeLine(content)
  4.     file.close()
  5. end
  6.  
  7. function Splitter(inputstr, sep)
  8.     if sep == nil then
  9.     sep = "%s"
  10.   end
  11.   local t, i = {}, 1
  12.   for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  13.     t[i] = str
  14.     i = i + 1
  15.   end
  16.   return t
  17. end
  18.  
  19. local programName = Splitter(shell.getRunningProgram(), "/")[2]
  20.  
  21. shell.run("delete "..programName)
  22. print("updating...")
  23. shell.run("pastebin get gkz5sgZ8 "..programName)
  24. term.clear()
  25. save("database/"..programName.."/state", "1")
  26. shell.run(programName)
Advertisement
Add Comment
Please, Sign In to add comment