Advertisement
Houshalter

ComputerCraft Auto Update System

Dec 19th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.69 KB | None | 0 0
  1. --update add name url
  2. --update remove name
  3. --update name
  4. --update all
  5. local a1, a2, a3, a4 = ...
  6.  
  7. local f, t = io.open('updateData'), {}
  8. if f then
  9.     local data = f:read('*a')
  10.     f:close()
  11.     t = loadstring('return '..data)()
  12. end
  13.  
  14. if a1 == 'add' then
  15.     t[a2] = a3
  16.     fs.delete(a2)
  17.     shell.run('pastebin', ('get %s %s'):format(a3, a2))
  18. elseif a1 == 'remove' then
  19.     fs.delete(a2)
  20.     t[a2] = nil
  21. elseif a1 == 'all' then
  22.     for name,url in pairs(t) do
  23.         fs.delete(name)
  24.         shell.run('pastebin', ('get %s %s'):format(url, name))
  25.     end
  26. else
  27.     fs.delete(a1)
  28.     shell.run('pastebin', ('get %s %s'):format(t[a1], a1))
  29. end
  30. local f = io.open('updateData', 'w')
  31. f:write(textutils.serialize(t))
  32. f:close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement