This third version is intended to be clearer and easier for reading, specially having in mind those not too advanced users, and also, because I am improving my English (thanks to BZ!) .
The BZFlag client has a command that allows us to save all the messages (all the text inside the game) into a simple text file in any moment, provided that we are logged into a server. It has 2 variations (typing previously "n" or "m" - public or team chat):
* All the commands are meaning to be without the quotation marks.
"/savemsgs" --> colored messages (using the ANSI codes)
"/savemsgs -s" --> uncolored messages ("stripping" the ANSI codes)
Then, we will obtain a file called "msglog.txt" into our BZFlag folder.
The problem with the ANSI color codes (some weird symbols and numbers inside the file) is that they ONLY run (or are shown) within terminals, for example the shell (black screen for commands) or the IRC (chat) ones; but also, if we wanted to copy/paste them into a text editor, it would be impossible. For solving this, it is necessary a program that does the conversion. First, we will use ANSIFilter for obtaining an HTML document (a common format) and, after, LibreOffice for obtaining a PDF document (an useful format for reading/annotating). Finally, we will automate the process and make some necessary changes putting all these into a shell script (program).
* We will use only Free/Libre Software (*). Please, read also the introduction of the script.
* About LibreOffice: I chose it because it was the only one option that worked and because of its quality (it has the LO team behind). All the other ones I found made the pages hard to read, by decreasing the font size when there were long lines (BZ has them often).
An example: Screenshots of a PDF file, including annotations: STEPS FOR GNU/LINUX:
(For Windows, see the next post. For Mac/other systems --> TESTS ARE WELCOME! - Please, send me a P. M.)
* BZ folder: "~/.bzf/" ("~" is expanded to the home directory).
1) Download the ANSIFilter source code from http://www.andre-simon.de/doku/ansifilt ... ilter.html.
2) Extract and compile it, using the shell. Doing just a "make" command, you will obtain the executable "ansifilter" file in the "src" folder. Copy it to your BZFlag folder.
3) Copy/paste this code into a simple text editor, save it as "logconverter.sh", and make it executable (right button/Properties/Permissions/ and check "Is executable", or run "chmod +x logconverter.sh"). Please, read the important note inside the file.
Code: Select all
#!/bin/bash # # LOGCONVERTER 1.0 - GNU/LINUX VERSION # ------------------------------------ # # Shell script for converting BZFlag logs ("/savemsgs" command) from ANSI colored messages to: # # 1 - HTML file: you will be able to read it into any navigator and to copy/paste it to an office # editor like LibreOffice (a) (using ANSIFilter (b)) # # 2 - PDF file: you will be able to read it into any PDF viewer and to add annotations if it is available, # as in Okular (c) (using just the LibreOffice command line converter) # # *** IMPORTANT *** # You will need to have in the same folder of this script: the "ansifilter" program, a BZ log file # called "msglog.txt" and LibreOffice installed in your system BUT NOT RUNNING AT THE # SAME MOMENT OF THE EXECUTION # # Tested with BZFlag 2.4.0 (STABLE) # Author: alpha1 # # More info at: # - http://forums.bzflag.org/viewtopic.php?f=2&t=18559 # - www.bzflag.org # # Links: # * All these programs, as BZFlag, are Free/Libre Software (www.fsf.org and www.gnu.org) # (a) www.libreoffice.org # (b) www.andre-simon.de/doku/ansifilter/en/ansifilter.html # (c) http://okular.kde.org # Adding top and bottom modifications: # top) for making the title white and bold # bottom) for setting back the default values of the console (echo $'\e[37;1m'; cat msglog.txt; echo $'\e[0m') > temp1.txt # Doing exchanges: # a) black color to grey (xterm) sed $'s/\e\[30m/\e\[38;5;248m/g' temp1.txt > temp2.txt # b) default color to white sed $'s/\e\[37m\e\[0;1m/\e\[0m\e\[37;1m/g' temp2.txt > temp3.txt sed $'s/\e\[0;1m/\e\[0m\e\[37;1m/g' temp3.txt > temp4.txt # Creating the HTML file and setting the document title ./ansifilter -d msglog --html temp4.txt > temp.html # Changing the background color to grey for the annotations can be seen sed $'s/<body>/<body bgcolor="#666666">/' temp.html > msglog.html # Deleting the temp files rm temp* # Generating the PDF file (*** optional but recommended - it can be commented ***) libreoffice --headless -convert-to pdf msglog.html # Deleting the "msglog.html" file (*** optional - it can be uncommented ***) # rm msglog.html
"./logconverter.sh" (without any arguments)
Attention: don't use it with bad purposes! Remember that the servers save logs too and you can't lie against them.
(*) Free/Libre Software: You have the rights to use, modify and redistribute it freely, with some restrictions. More info at:
* Note: the message window in BZFlag has a limited memory size (called "cache memory"). As the "/savemsgs" command will ALWAYS use the "All" mode ("all kind of messages"), the amount of pages you are seeing in your screen is what you will get saved. You can use it several times, though, and the new text will be always added at the bottom part. If you lost some chat messages, you can switch to the "only Chat mode" (Shift+F2) and use, instead, the screenshots (F5).