Advertisement
Marlingaming

System Alias Manager

Apr 5th, 2022 (edited)
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. local tArg = {...}
  2.  
  3. function startup()
  4. local file = fs.open("os/Files/Alias.txt","r")
  5. local Text = file.readAll()
  6.  
  7. local Table = textutils.unserialize(Text)
  8. for i = 1, #Table do
  9. shell.setAlias(Table[i][2],Table[i][1])
  10. end
  11. file.close()
  12. end
  13.  
  14. function AddAlias(a,b)
  15. local file = fs.open("os/Files/Alias.txt","r")
  16. local Text = file.readAll()
  17.  
  18. local Table = textutils.unserialize(Text)
  19. Table[#Table + 1] = {a,b}
  20. file.close()
  21. local Doc = fs.open("os/Files/Alias.txt","w")
  22. Doc.write(textutils.serialize(Table))
  23. Doc.close()
  24. end
  25.  
  26. function Setup()
  27. local Table = {{"startup/AliasManager.lua","AliasMan"}}
  28. local Doc = fs.open("os/Files/Alias.txt","w")
  29. Doc.write(textutils.serialize(Table))
  30. Doc.close()
  31. end
  32.  
  33. if tArg[1] == nil then
  34. startup()
  35. elseif tArg[1] == "setup" then
  36. Setup()
  37. elseif tArg[1] == "add" then
  38. AddAlias(tArg[2],tArg[3])
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement