Advertisement
Lordeah18

Untitled

Dec 29th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. --Remove the extension from the file name
  2. function remove_extension(path)
  3. return path:match("(%a+)%.?.-")
  4. end
  5.  
  6.  
  7. function execute(script_api)
  8. --Initialize the api
  9. local script = require(script_api)
  10.  
  11. ok, err = pcall(pulverizer_run)
  12. if not ok then
  13. if err == "Terminated" then
  14. return true
  15. end
  16. end
  17. return false
  18. end
  19.  
  20.  
  21. function main()
  22. scripts_filenames = fs.list("scripts")
  23.  
  24. --No files in startup directory
  25. if #scripts_filenames == 0 then
  26. return
  27. end
  28.  
  29. scripts_run = {}
  30. for _,v in ipairs(scripts_filenames) do
  31. --Remove .lua from the path because api doesn't like it :(
  32. script_stripped = remove_extension(v)
  33. --Get the api
  34. script_api = require(script_stripped)
  35.  
  36. --
  37. table.insert(scripts_run, script_api)
  38. end
  39.  
  40. --Require API didn't grab the files correctly
  41. if #scripts_run == 0 then
  42. return
  43. end
  44.  
  45. is_terminated = false
  46. while not is_terminated do
  47. for _,v in ipairs(scripts_run) do
  48. is_terminated = execute(script_api)
  49. end
  50. end
  51. end
  52.  
  53.  
  54.  
  55. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement