I also wanted to understand more from lua scripts. First, I wanted to deal with the data logging. I copied the most important things from rawopint. I hope that I was allowed to do so.
Yes, you are welcome to. I released under GPL, so technically a script that includes it should also be GPL, but this isn't something I'm going to worry about.
What I'm wondering, should not you put these functions into a generic module so everyone could use it?
That was my original plan (and I may still get around to it someday), but I found putting all the "modules" inline in the script makes it easier to distribute and avoids compatibility issues. The down side is copy/pasting it into multiple scripts if I update.
Some general information on the log module. c_joerg probably already knows all this but maybe useful for anyone else reading:
The idea is to generate a csv with one row per short, but be able to record values wherever they are naturally available in code.
The columns and some other options are defined using log:init.
Values are recorded with log:set{colname=value,...}
Unset values are just logged as empty cells, so there's no harm if something isn't set on a particular code path.
If a value is set more than once before the row is written, the last value is used.
log:set takes care of things like exposure values nicely, but it's also useful to log some free-form text for diagnostic messages. This is done with logdesc, which acts like printf and puts the result in the desc column delimited /. logdesc isn't strictly part of the log module, log:text_logger is used to create functions like this bound to a particular column.
The values are stored in a lua table until log:write() is called.
One thing to watch out for is that the module current doesn't escape values written to the log, so values should not include , or "
There are two special column types: function and table, defined in init using the 'funcs' and 'tables' sections.
function columns get their value from a function at when a row is written. This is useful for things like temperature or free memory.
Table columns append values to table each time set is called. When write is called, all the values are output to the cell, delimited by the delimiter defined in init. So far I've only used this for the desc column.