I want to make a backup tool, but instead of having to key in the project name manually, is there a way to get the project name?
Not that I know of,
You shouldn’t need it I think.
saveProjectTab for example, can take a project name optionally, but will just use the current project by default.
@JakAttak - What I plan on doing is saving a text file to Dropbox. I want the name of the file to be the name of the project.
You could use project info. Add something like this to the setup of the projects you’re saving, or put it in a backup library that’s a dependency of every project you backup:
version = 1.0 saveProjectInfo("Description", "My Awesome Project v"..version) saveProjectInfo("Author", "Me") saveProjectInfo("Version", version)
@Saturn031000. Oh. A trick you could try, is getting the first line of the Main file. Every project has the name there when first created.
@JakAttak - Thanks for the idea! Here’s the function I wrote to find the name:
function findProjectName() local main = readProjectTab("Main") local beginner = 4 local ender = 0 if string.find(main, "-- Use this")~=nil then ender = string.find(main, "-- Use", 3)-3 else ender = string.find(main, "function", 5)-3 end local title = string.sub(main, beginner, ender) return title end
@Saturn031000 Here’s a version.
-- getProjectName function setup() print(projectName()) end function projectName() local str=readProjectTab("Main") if string.sub(str,1,3)=="-- " then return(string.sub(str,4,string.find(str,"\ ")-1)) end end