Print Battle Log to Text File

ZServ

Veteran
Veteran
Joined
Jun 16, 2014
Messages
260
Reaction score
71
Primarily Uses
Hey there! Looking for a script that would print the battle log to a text file in the games folder. Mainly for number crunching purposes. I've attempted to write this myself, but to no avail.


Here's the snippet I have thus far:


class Window_BattleLog < Window_Selectable

module PrintToFile
FILENAME = "outputtesting.txt"
end

# if $imported["YEA-CombatLogDisplay"]
# alias combatlog
#File.open(PrintToFile::FILENAME, 'a+') {|f| f.write(@lines) }
# end
File.open(PrintToFile::FILENAME, 'a+') {|f| f.write(@lines) }
end


I know that I should be accessing the Scene_Battle, and have some form of check for if a battle is ended, and write that line as well. Or, alternatively, only print at the end, assuming that I can dump the entire log. That was why I originally was attempting to import the Yanfly Ace Engine combat log stuff, as I figure to display everything, it must *have* everything stored somewhere.

I don't necessarily *need* someone to just write it for me, but I'd love some help and I'd be massively appreciative if someone could point me in the right direction.
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
I don't necessarily *need* someone to just write it for me, but I'd love some help and I'd be massively appreciative if someone could point me in the right direction.
If that's the case, this script here might help you figure out how to do it.
 

ZServ

Veteran
Veteran
Joined
Jun 16, 2014
Messages
260
Reaction score
71
Primarily Uses
If that's the case, this script here might help you figure out how to do it.
Hrm. Perhaps I'm missing something, but I have no problems with *creating* the file. The file creates just fine, in fact, it'll open an existing file if it matches the name and append the new info to it, as well. The current issue is that A; it doesn't run more than once, so I assume I'm calling the wrong window. B; I'm failing to figure out the proper call to print the @lines variable from Window_BattleLog. Unless @lines is actually not the proper variable, in which case I'm just blind. 


Back to the drawing board!
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
For window battle log, @lines is being cleared from time to time. So you have to write the data to the file accumulatively before they are being cleared. Overwriting @lines will not work as well since the new @lines will be empty after cleared and you will be overwriting your file with empty data.
 
Last edited by a moderator:

ZServ

Veteran
Veteran
Joined
Jun 16, 2014
Messages
260
Reaction score
71
Primarily Uses
For window battle log, @lines is being cleared from time to time. So you have to write the data to the file accumulatively before they are being cleared. Overwriting @lines will not work as well since the new @lines will be empty after cleared and you will be overwriting your file with empty data.
To be a tad technical, I'd be appending the file with empty data, not overwriting, but yes. You're still correct.

Here's what I'm currently working with:


class Window_BattleLog < Window_Selectable

module PrintToFile
FILENAME = "outputtesting.txt"
WRITE_LINES = "\n" + @lines.to_s
end
alias PrintToFile_Refresh refresh
def refresh
File.open(PrintToFile::FILENAME, 'a+') {|f| f.write(PrintToFile::WRITE_LINES) }
draw_background
contents.clear
@lines.size.times {|i| draw_line(i) }
end
end


It's now printing on every refresh (from what I can tell from the million empty lines), but apparently I don't get to it before it auto-clears. But additionally, there's the concern of if it's updating every frame, how will I parse out duplicate information?


Jeez, something as simple as this and I'm *still* an idiot lol.
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
It's now printing on every refresh (from what I can tell from the million empty lines), but apparently I don't get to it before it auto-clears. But additionally, there's the concern of if it's updating every frame, how will I parse out duplicate information?
Why printing it on a separate update?


Thought you were looking into the methods in window battle log class? You should be able to find the few methods used to print the text to the screen before the contents are cleared there. Simply add your code right after the draw text part and before the clearing part will do.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,050
Messages
1,018,548
Members
137,835
Latest member
yetisteven
Top