Guest User

Unitale/CYF mod path and name finder

a guest
Aug 27th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. local self = {}
  2.  
  3. -- get the actual mod path right away!
  4. local testError = function()
  5.     CreateProjectile("asdbfiosdjfaosdijcfiosdjsdo", 0, 0)
  6. end
  7.  
  8. local _, output = xpcall(testError, debug.traceback)
  9.  
  10. -- find the position of "Sprites/asdbfiosdjfaosdijcfiosdjsdo"
  11. local SpritesFolderPos = output:find("asdbfiosdjfaosdijcfiosdjsdo") - 10
  12. output = output:sub(1, SpritesFolderPos)
  13.  
  14. -- get the full path to the mod file
  15. local path = output:sub(output:find("Attempted to load ") + 18)
  16. path = path:gsub("/", "\\")
  17. self.modPath = path
  18.  
  19. -- get the name of the mod, too!
  20. -- find the position of the last slash in the file name
  21. local lastSlashIndex = 0
  22. for i = 1, #output do
  23.     if output:sub(i, i) == "/" then
  24.         lastSlashIndex = i
  25.     end
  26. end
  27.  
  28. -- get the name of the mod itself
  29. local folderName = output:sub(lastSlashIndex + 1, SpritesFolderPos)
  30. self.modName = folderName
  31.  
  32. return self
Advertisement
Add Comment
Please, Sign In to add comment