Append to variable or append to file?

Posted by KaiserBear on Tue 13 Oct 2015 09:10 PM — 2 posts, 13,116 views.

#0
Hello,

I'm trying to make it so that when a certain thing happens a trigger catches it and saves the data. An example of the output I'm trying to catch is:

(Chat): Bob says, "Hello."

And my trigger would be something like (Chat): * says, *

The goal is to save the entire thing either to a variable in a growing log (depending on how large variables can be) or a file. If it's a file, I also need to know how I could then create a command to print to output the contents of the file (which is why I prefer a variable, since I could just use GetVariable).

My thought it something like:

incomingText = '"(Chat): " .. %1 .. " says, " .. %2'


But I'm not sure how to then append 'incomingText' to either a variable or file. Any help would be great.
Australia Forum Administrator #1
I'm not sure about your use of quotes there, but to append to a variable:


var = var .. newstuff


For a file you could open a file "for appending" and write to it. You could also keep the file open and keep writing.

http://www.gammon.com.au/scripts/doc.php?general=lua_io