I'm working on making a plugin that shows info on a script when it is selected, and know how to test for the selection and get the name, but how do I count how many lines it has?
You would have to get the source of the script(as Spongocardo stated) and reconstruct the entire text-I had already done something like this. This is heavily based off of BuildIn Libraries' Helper Library.
function getSource(s) local lines = {}; local str = ""; for i = 1, string.len(s.Source) do if (string.sub(s.Source, i, i) == "\n") then lines[#lines+1] = str; str = ""; else str = str..string.sub(s.Source, i, i); end end if (str ~= "") then lines[#lines+1] = str; end return lines; end
Now you could do #lines to find how many lines it has.