I've been searching for some time, but haven't been able to find a solution.
I'd like to be able to start logging from a script, be it through Triggers or Aliases what-have-you. Perhaps I've missed the function somewhere? My research did turn up an old thread stating that "automatic logging" would definitely be a feature; has it yet to be implemented?
Logging via Script
Re: Logging via Script
Such a function has been requested before. It's on my todo list.
Re: Logging via Script
With the release of 1.0, I thought this might be an appropriate time to ask about progress on exposing logging to scripting.
Re: Logging via Script
It will be in 1.0.3.
Re: Logging via Script
Was this not added in 1.0.3 or am I just not finding it in the documentation?
Oh, and is there a way to list all global functions in mudlet somehow?
Oh, and is there a way to list all global functions in mudlet somehow?
Re: Logging via Script
It was added, but you may be right that it isn't listed in the manual yet.
startLogging(true) starts the logging startLogging(false) stops it. It will always log to a file in the Mudlet home directory, and as far as I know there's currently no way to change that. If you want to log to somewhere else, you'll have to write your own function for it.
(E.g:
logfile = assert(io.open ("Your Desired Path and File Name","a"))
enableTrigger("log")
And a trigger named "log" that matches on every single line (^.*$) and does: logfile:write(line.."\n")
And finally a function to close the log:
logfile:close()
disableTrigger("log")
)
As for displaying all functions: Well, I don't know about restricting it to the predefined Mudlet functions, but since the global table _G holds all functions of Mudlet (predefined and the ones you defined) you can do it with something like:
(That's just some really quick and dirty code, to go through _G, check whether something is a function, filter out your Aliases, Triggers, etc. and display the remaining ones.)
P.S. Quite an interesting thing to do, as I just noticed. I found some functions there that I had no clue existed.
Of course, it would also be nice to know what arguments those functions take and what they do...
startLogging(true) starts the logging startLogging(false) stops it. It will always log to a file in the Mudlet home directory, and as far as I know there's currently no way to change that. If you want to log to somewhere else, you'll have to write your own function for it.
(E.g:
logfile = assert(io.open ("Your Desired Path and File Name","a"))
enableTrigger("log")
And a trigger named "log" that matches on every single line (^.*$) and does: logfile:write(line.."\n")
And finally a function to close the log:
logfile:close()
disableTrigger("log")
)
As for displaying all functions: Well, I don't know about restricting it to the predefined Mudlet functions, but since the global table _G holds all functions of Mudlet (predefined and the ones you defined) you can do it with something like:
Code: Select all
for k,v in pairs(_G) do
if type(v) =="function" and not
(string.match(k,"^Trigger%d+$") or string.match(k,"^Alias%d+$") or string.match(k,"^Key%d+$") or string.match(k,"^Timer%d+$")) then
echo(k.."\n")
end
end
P.S. Quite an interesting thing to do, as I just noticed. I found some functions there that I had no clue existed.
Of course, it would also be nice to know what arguments those functions take and what they do...
Re: Logging via Script
*cough* well check TLuaInterpreter.cpp for that. Let me know which ones are missing besides this one, I'll work on this in the weekend
Re: Logging via Script
I know about it, but it looks too ugly. The source code isn't commented much anyway, and it wouldn't be integrated with the main part... so doesn't really help the resource problem in any way.