gogutier Posted August 11, 2022 Share Posted August 11, 2022 Probably a noob question but how do I make a new line on a txt file using WriteStringToFile function? I understand it should be with '%r' but it doesn't work. I've tried the excact same example showed on geckwiki and still it does not apply the carriage return, it keeps writing on the same line instead. example: WriteStringToFile "data_file.txt" 1 "Two times four is %g and no more.%rIts name is %n" intVar refVar Any help is welcome. Link to comment Share on other sites More sharing options...
ebizoe Posted August 20, 2022 Share Posted August 20, 2022 I would do it like this: WriteStringToFile "data_file.txt" 1 "Two times four is %g and no more." intVar WriteStringToFile "data_file.txt" 1 "Its name is %n" refVar or: aArray = ar_List ("Two times four is " + $intVar + " and no more."), ("Its name is " + (GetName refVar)) forEach aIter <- aArray svString = *aIter WriteStringToFile "data_file.txt" 1 $svString loop Link to comment Share on other sites More sharing options...
gogutier Posted August 20, 2022 Author Share Posted August 20, 2022 Thanks for your suggestion but sadly it didn't work. It keeps adding text to the same line instead of creating a new one. Link to comment Share on other sites More sharing options...
ebizoe Posted August 20, 2022 Share Posted August 20, 2022 That's strange. I double checked my code in my previous post, and they both do work as I intended.The result "data_file.txt" is like this for both code: Two times four is 10 and no more. Its name is Bobby Pin Two times four is 10 and no more. Its name is Bobby Pincode: int intVar = 10 ref refVar = BobbyPin WriteStringToFile "data_file.txt" 1 "Two times four is %g and no more." intVar WriteStringToFile "data_file.txt" 1 "Its name is %n" refVar array_var aArray = ar_List ("Two times four is " + $intVar + " and no more."), ("Its name is " + (GetName refVar)) forEach array_var aIter <- aArray string_var svString = *aIter WriteStringToFile "data_file.txt" 1 $svString loop And interestingly, if I put "%r" on the end of each string data, "data_file.txt" would look like this: Two times four is 10 and no more. (empty line) Its name is Bobby Pin (empty line) Two times four is 10 and no more. (empty line) Its name is Bobby Pin (empty line) code: WriteStringToFile "data_file.txt" 1 "Two times four is %g and no more.%r" intVar WriteStringToFile "data_file.txt" 1 "Its name is %n%r" refVar array_var aArray = ar_List ("Two times four is " + $intVar + " and no more.%r"), ("Its name is " + (GetName refVar +"%r")) forEach array_var aIter <- aArray string_var svString = *aIter WriteStringToFile "data_file.txt" 1 $svString loop So, seems like "%r" actually does something.By the way, I use this script function in my mod to store array data to a text file, one array entry per line. If you'd like to check it out. Here is my mod. Link to comment Share on other sites More sharing options...
gogutier Posted August 23, 2022 Author Share Posted August 23, 2022 (edited) Thanks a lot for your help. I tried directly using your mod (very neat mod btw) and adding items to the custom filter, and it also adds them to the same line! I guess I have some plugin or mod that affects the WriteToFile function in my PC (quite an old one to play FNV, maybe that's related as well). I'll try installing the game in a newer PC and see if somehow that fixes the problem. Edited August 23, 2022 by gogutier Link to comment Share on other sites More sharing options...
ebizoe Posted August 23, 2022 Share Posted August 23, 2022 I tried the latest JIP LN NVSE Plugin v56.72 (I was using v56.52), and found that "%r" on WriteStringToFile works as it should.code: int intVar = 10 ref refVar = BobbyPin WriteStringToFile "data_file.txt" 1 "Two times four is %g and no more.%rIts name is %n" intVar refVar "data_file.txt": Two times four is 10 and no more. Its name is Bobby Pin So, maybe your xNVSE, JIP LN NVSE Plugin and JohnnyGuitar NVSE need to be updated to the latest version? Link to comment Share on other sites More sharing options...
gogutier Posted September 12, 2022 Author Share Posted September 12, 2022 So far no luck but I'll post here when it works. Link to comment Share on other sites More sharing options...
ebizoe Posted September 15, 2022 Share Posted September 15, 2022 Take your time. It could be very small things that we overlooked.However, since I use this script function in my mod, I'm very curious to learn what causes this problem. So if you find it out, please don't forget to report it here. Link to comment Share on other sites More sharing options...
Recommended Posts