Advertisement
Marlingaming

Boot - API manager

Apr 6th, 2022 (edited)
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. local tArg = {...}
  2.  
  3. local Path = "boot/files/apis.txt"
  4. local APIs = {}
  5.  
  6. function AddAPI(Pro)
  7. local file = fs.open(Path,"r")
  8. APIs = textutils.unserialize(file.readAll())
  9. file.close()
  10. APIs[#APIs + 1] = Pro
  11. local Doc = fs.open(Path,"w")
  12. Doc.write(textutils.serialize(APIs))
  13. Doc.close()
  14. end
  15.  
  16. function LoadAPI()
  17. local file = fs.open(Path,"r")
  18. APIs = textutils.unserialize(file.readAll())
  19. file.close()
  20. for i = 1, #APIs do
  21. os.loadAPI(APIs[i])
  22. end
  23. end
  24.  
  25. function Setup()
  26. APIs = {"os/System/Tools/App.lua","os/System/Tools/fsAdv.lua","os/System/Tools/Sec.lua"}
  27. local file = fs.open(Path,"w")
  28. file.write(textutils.serialize(APIs))
  29. file.close()
  30. end
  31.  
  32. if tArg[1] == "add" then
  33. AddAPI(tArg[2])
  34. elseif tArg[1] == "start" then
  35. LoadAPI()
  36. elseif tArg[1] == "setup" then
  37. Setup()
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement