Answered by
3 years ago Edited 3 years ago
i was trying to find the cause of the issue for a long time but it's kind of hard, i will make an update if i find out about it. what i could find out was that it seems to match some character after some non-empty newlines which returns nil when put into string.byte
.
the solution for your case is to just string.split
, there really is no need for gmatch
, split the string by newlines:
01 | local rptext = ui.Frame.Replace.Text |
02 | local withtext = ui.Frame.With.Text |
04 | local lines = string.split(item.Source, "\n" ) |
06 | for i, line in ipairs (lines) do |
07 | lines [ i ] = string.gsub(line, rptext, withtext) |
10 | item.Source = table.concat(lines, "\n" ) |
notice there is no reason to check if string.find
finds something, gsub
won't replace anything if it's not found, you are redundantly doing 2 pattern searches.
now let's get to feedback part, your plugin is absolute trash... like who can't just click Ctrl + H you self appointed programmer ;-;