DeeDubb Posted August 28, 2022 Share Posted August 28, 2022 For several larger projects I am working on, I am trying to simplify the process by creating a mod for Fallout 4 that will ideally: Listen for changes on a file If there are changes to the file, load the text from the file as a console command Have a method to prevent rerunning the same command over and over (possibly by clearing the contents of the file) The reason why this mod would be so effective for my needs is because I could create scripts in other languages which write console commands to the file and the mod will automatically execute those in the game, allowing me to link other systems seamlessly into the games. I do not mind using F4SE, but it's been tough to find any documentation to help. I have seen that Skyrim SE has support for Papyrus SE with MiscUtil to read and write from a file, but I haven't seen the same support for Fallout 4. Any guidance would be greatly appreciated. Link to comment Share on other sites More sharing options...
RaidersClamoring Posted August 29, 2022 Share Posted August 29, 2022 I'd love to know how to do this as well. So far no luck but I've gathered that RegisterForExternalEvent() is where the solution may possibly lie.As for loading the file as batch command via script, I don't know any other way than using SUP_F4SE, which is excellent and every mod creator should have it anyway.It has this:string Function ReadStringFromFile(string nameA, int a, int b) global native;/ string Function ReadStringFromFile(string s_FilePath, int iStartLine, int iLineCount) Reads from file and puts contents in string Example: Debug.Notification("Reading 0 to 20 lines from file >>>" + ReadStringFromFile("CreationKitPrefs.ini",0,20))Together with a remote call to Scaleform you will be able to put this info into a console command Function Execute() Global var[] arguments = new var[1] arguments[0] = ReadStringFromFile("ModFolder\\GeneratedBat.txt", 0, 1) as string UI.Invoke("Console", "root1.AnimHolder_mc.Menu_mc.BGSCodeObj.executeCommand", arguments)EndFunction You could, conceivably, instead of installing SUP have an external windows bash file of some sort (Visual basic) sitting inside My Games/Fallout4/Logs/Script/User that will be sniffing for a file with a particular name, and you generate the file using Debug.OpenUserLog() and Debug.TraceUser().Something like: Function PutFile() Global String UserLogName = "" String BatCommand = "" ; do the stuff, defining UserLogName and BatCommand Debug.OpenUserLog(UserLogName) Debug.TraceUser(UserLogName, BatCommand as string) Debug.CloseUserLog(UserLogName)EndFunction But how to do the rest in this case is anyone's guess. Link to comment Share on other sites More sharing options...
RaidersClamoring Posted August 29, 2022 Share Posted August 29, 2022 Sorry forgot to add you can write the bat using SUP as well bool Function WriteStringToFile(string sFilePath,string sText, int iAppend) global native;/ bool Function WriteStringToFile(string sFilePath,string sText, int iAppend) Writes string to following file. If file doesn't exist - it will be created. iAppend parameter: 0 - clean contents of file before writing your string; 1 - append string to the end of the file; 2 - append string to the end of the file with a new line; WriteStringToFile("aaOutput1.txt","MyText",0) WriteStringToFile("aaOutput1.txt","MyText2,",1) WriteStringToFile("aaOutput1.txt","MyText3-Starts with a new line,",2) File output: myTextMyText2, MyText3-Starts with a new line, Link to comment Share on other sites More sharing options...
Recommended Posts