So a couple of things I was trying to figure out,
1. how to print to another text console, and
2. how often register_periodic will call a routine.


So how to send lua print output to another text console.

I would get lots of output information that would mess up my command line, so why not send it to another window?

On ubuntu 17.10, you can launch an xterm with a command line like:
Code
xterm -e "tty;cat" &
So it executes the program tty which prints something like "/dev/pts/3" on the top line which is the pseudoterminal assigned to the terminal and then executes cat. The & is to run it in the background so you get your console back.

I tried it with "gnome-terminal -- tty;cat" but it didn't seem to work, giving me some kind of error.

I launch mame with this command line:

Code
./mame64 a2600 stampede -plugin console -debug -window  2>/dev/pts/3

so the 2> redirects stderr to my freshly created xterm at /dev/pts/3.

and any error messages from lua goes to stderr and I can also print stuff directly with

Code
io.stderr:write("This goes to stderr\n")



I was trying to figure out how often a routine registered to emu().register_periodic would get called:

Code
function testperiodic() if not stopprint then if cycles == nil then cycles = 1 end io.stderr:write(" cycles="..(cycles).."  "..os.date().."\n") if cycles then cycles=cycles+1 end end end

-- same function on multiple lines:

function testperiodic() 
  if not stopprint then 
    if cycles == nil then cycles = 1 end 
    io.stderr:write(" cycles="..(cycles).."  "..os.date().."\n") 
    if cycles then cycles=cycles+1 end 
  end 
end

emu.register_periodic(testperiodic)


-- and when you want to stop the printing, set stopprint to true
-- stopprint=true

and you get output like:
Code
 cycles=1  Mon 04 Dec 2017 04:05:44 PM EST
 cycles=2  Mon 04 Dec 2017 04:05:44 PM EST
 cycles=3  Mon 04 Dec 2017 04:05:44 PM EST
 cycles=4  Mon 04 Dec 2017 04:05:44 PM EST
 cycles=5  Mon 04 Dec 2017 04:05:44 PM EST
 cycles=6  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=7  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=8  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=9  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=10  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=11  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=12  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=13  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=14  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=15  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=16  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=17  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=18  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=19  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=20  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=21  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=22  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=23  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=24  Mon 04 Dec 2017 04:05:45 PM EST
 cycles=25  Mon 04 Dec 2017 04:05:46 PM EST

And it looks like you get around 20 cycles per second.

And if you want other terminal output windows, you can use io.open like so:
Code
[MAME]> out2 = io.open("/dev/pts/4","w")
[MAME]> print(out2)
file (0x56300b8219b0)
[MAME]> out2:write("hello wont be seen until newline")
[MAME]> out2:write("hello\n")
[MAME]> out2:write("wont see me until flush")
[MAME]> out2:flush()