I was trying to clean up my code and put some things into the luaprinter constructor so they would be done automatically done, but it seems to make it not work. So strange. And printfs in the constructor don't appear until I exit mame.


The printfs that make "Scooby 8510" and "Scooby 8511" don't appear until exiting mame, yet the initvalue gets set properly to 3333.

But if I move routines into the constructor all sorts of weird things happen. So I'll leave it outside for now since I've been fiddling with this for a day...gcc problems on Ubuntu?


Code
luaprinter(device_t & thisdevice, int testvalue){ 
        m_lp_mydevice = &thisdevice; 
        time(&m_lp_session_time);  
        initvalue = testvalue;
        printf("\n\nInit Luaprinter Scooby %d\n",testvalue);
        initvalue = 33333;
        };



Code
[MAME]> lp = manager:machine().printers for i=1,#lp do print( lp[i]:getprintername(), #lp, lp[i]:getinitvalue(), lp[i]:simplename()) end
2020-09-16 08-25-19 apple2p-sl1-parallel-pic_ctx-luaprinter	3	33333	apple2p a2bus_slot a2pic centronics centronics_luaprinter centronics
2020-09-16 08-25-19 apple2p-sl2-ssc-ssc_rs232-luaprinter	3	33333	apple2p a2bus_slot a2ssc rs232 serial_luaprinter rs232
2020-09-16 08-25-19 apple2p-sl4-parallel-pic_ctx-ap2000	3	33333	apple2p a2bus_slot a2pic centronics ap2000 centronics


(exit mame here)

[MAME]> 

Init Luaprinter Scooby 8510

Init Luaprinter Scooby 8511

Init Luaprinter Scooby 810
Average speed: 100.00% (31 seconds)
sdl_kill: closing audio
Enter sdlwindow_exit
Leave sdlwindow_exit

after putting code in the constructor I get strange behavior:

Code
[MAME]> print( manager:machine().luaprinters[1]:getprintername(), #manager:machine().luaprinters)
error: 	std::bad_alloc
[MAME]> print( #manager:machine().luaprinters)
56