[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Append to variable or append to file?
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Append to variable or append to file?

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


Posted by KaiserBear   (9 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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
[Go to top] 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.


1,962 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]