We need something similar to REPLACE_BCS_BLOCK but for LUA and MENU files format. Let's say I want to replace this code:
--This code is different if we're sod or BG
local lineCount = 1
local fullStr = Infinity_FetchString(entryId)
for line in string.gmatch(fullStr, "[^\r\n]+") do
if(lineCount == 1) then
--objective text is first line.
objective.text = line
end
if(lineCount > 1) then
--entry text is everything after first
entry.text = entry.text .. line .. "\n"
end
lineCount = lineCount + 1
end
if(lineCount == 2) then
--it looks like sometimes entries are just an unbroken paragraph
--in this case the entry should get the paragraph and the objective gets nothing
--note lineCount == 2 is a bit misleading, there's only one line in this case.
entry.text = objective.text
objective.text = Infinity_FetchString(quest.text)
end
Doing it with REPLACE_TEXTUALLY would be insane. And that's just a small portion of the file. Some GUI mods needs to replace hundreds of lines at once. Due to this problem all GUI mods are incompatible with one another because they always overwrites whole files rather than replacing part of text within these files. Perfectly the function should work exactly the same as R_B_B, so with ON_MISMATCH and ignoring blank lines and tabs when finding the match.