Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Append to variable or append to file?

Append to variable or append to file?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by KaiserBear   (9 posts)  Bio
Date Tue 13 Oct 2015 09:10 PM (UTC)
Message
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.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 13 Oct 2015 09:37 PM (UTC)
Message
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

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


12,449 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.