|
unrealtor Beginner
Joined: 23 May 2020 Posts: 19
|
Posted: Tue Feb 08, 2022 5:43 pm
Character Info Logging |
I am looking to log the output of the mud's info command, which is about 20 lines, to a file by the name of the character. So far, I have found that the best way to capture the lines is with the #C+/- to a window, using a beginning and end trigger. I now need to write this data to a named file, and while I don't actually need a window, I can live with it being tabbed. I am hoping to avoid a complex set of multistate triggers to detect each line and write line by line to a file. I had tried this and the client seemed to "lock-up" while it was going through the set of triggers.
Sample of the game output:
You are Tom *********
*** (16-ish other lines of data to log) ***
You are affected by:
Current setup:
- start trigger: #TR {You are @myChar *, * [(%d)] *.} {#CLR CharInfo;#cap CharInfo;#C+ CharInfo} // which clears the window output, writes the triggered line, then the rest of the lines
- end trigg: #TR {You are affected by:} {C-}
Goal:
- write output of captures (or contents of window CharInfo) to @myChar.txt, as the same multi-lined readable format as the source
- preferably replace the file's content with the new output
Anyone able to assist or point me in a direction?
Thanks! |
|
|
|
hpoonis2010 Adept
Joined: 18 Jun 2019 Posts: 279
|
Posted: Tue Feb 08, 2022 7:43 pm |
#FILE command used to open a file for reading/writing
#WRITE command to write to this file.
#CLOSE will close the opened file. |
|
|
|
unrealtor Beginner
Joined: 23 May 2020 Posts: 19
|
Posted: Tue Feb 08, 2022 8:21 pm |
I understand those commands, but how do I direct the captured input into the output of a #write? I don't see a way to store the captured content as a variable. I thought maybe by using a window to "cache" it, I could maybe somehow grab it from there, but I am just not seeing a way.
|
|
|
|
hpoonis2010 Adept
Joined: 18 Jun 2019 Posts: 279
|
Posted: Wed Feb 09, 2022 5:40 pm |
From the documentation:
#FILE 1 log.txt
#WRI 1 {logged onto Dark Castle}
append the string to the end of text file number 1.
You should be able to write %line(num) to your text file. I have not used text files but, in theory, this should just be
#FILE 1 textfile.txt
#WRI 1 {%line(0)}
#CLOSE 1 |
|
|
|
unrealtor Beginner
Joined: 23 May 2020 Posts: 19
|
Posted: Thu Feb 10, 2022 5:11 pm |
Thank you for your attempts to help, but so far, no dice...
I put #WRI 1 {%line(0)} inside my trigger action, after the C+ (even took it out), and %line(0) is returning the trigger's captured string (my first line of character info or the same as #cap). I checked %line(1), and it shows the last line (about 28 lines later). %line(2) is above and so forth, backwards up the output stack. I thought about looping this 28(?) times, but there is potential for other unexpected output to be in the middle of the triggered text and the ending lines, like says/chats/someone_enters_room, so I would end up having to again create a multistate trigger to ignore non-matches; else potential to miss x lines of the start of desired text. %line also completely ignores #C+, when put after, and is only working off the initial triggered text. (Also tried %clip() after #C+, but instead of the output, it put "#C+ CharInfo" in my file).
My goal here is to directly capture to variable (or access) the output of everything between #C+ and #C-, so that x lines can be written to file. Again, I am trying to avoid multistate trigger, because aside from the complex setup of matching 20sih consecutive lines, my generic tests showed the client momentarily locking when trying to execute, which could cause player death if unable to flee. |
|
|
|
unrealtor Beginner
Joined: 23 May 2020 Posts: 19
|
Posted: Tue Feb 15, 2022 4:51 pm |
I retried a different way of using multistate triggers, my client is no longer locking up, and was able to write the files I need. Thanks for the replies.
|
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|