Closed leviathan13 closed 5 years ago
I just did something similar
Its very important that you have a whitespace/newline in the to be appended file
So your second file should lead with a empty line
Yes, I also did some testing and the issue is that if you start a file with an empty line, that file will work only in the specific case of it being loaded after a file that doesn't end with an empty line, otherwise the file will break in any other circumstances. That is a very specific case that can only work locally for a specific mod configuration, it is certainly not a "good practice". If possible, I'd like for people to be able to load their mods without worrying about these peculiar cases.
Anyway, it seems that the best compromise is to end the file with an empty line... that does seem to not cause any issue regardless of the load order. However, if this is something that can be addressed automatically by ModTek I think it's the best case. Otherwise, at the very least we should inform people about this, like with the documentation, because it can be easily overlooked.
I hope I do not sound like I want to press the devs in any particular way (it's fine either way), I just want to raise awareness of such cases that I discovered myself so that it could save some time to other people that might have the same issue.
it causes an issue with multiple appended files
In your previous ticket, I did say:
These files only include the lines that you want to appear at the end of the file and should include a newline at the end of the last line
Regarding an automated solution, that'd be the best route, but it does complicate an otherwise simple implementation.
That's true... apologies, but your newline comment flew over my head before I did actually try that method.
I think this should be added to the examples of the documentation. I'd imagine that would still be time consuming, so if you'd like I can provide a draft text to save you some time.
Thanks again for bearing with me!
Hello, if two (or more) mods use the
"ShouldAppendText": true
method to append lines to the same itemCollection file, there is a chance the file won't work anymore. By inspecting the generated merged file in ModTek cache, I noticed that the reason as why this happened is because if the first mod doesn't end with an empty new line, the second mod loaded will "append" the text without adding a new line, thus braking the file. E.g.:Both mods added stuff to itemCollection_Components_base.csv. The first mod ends with
MOD1ITEM,MechPart,0,10
MOD1ITEM,MechPart,0,10
The second mod starts with
MOD2ITEM,JumpJet,0,10
MOD2ITEM,JumpJet,0,10
The merged file ended up with
MOD1ITEM,MechPart,0,10
MOD1ITEM,MechPart,0,10MOD2ITEM,JumpJet,0,10
MOD2ITEM,JumpJet,0,10
(I replaced the names to simplify the example). Both mods work fine individually and they also work if you manually correct the new lines at the start/end. However shouldn't ModTek take care of that automatically? If not, maybe I'll write this in the documentation somewhere to improve the compatibility between mods.