Here’s the screensaver code I created. It should be enough to get you going on an object that will take care of what you want. Its essentially the same concept of doing something after a period of inactivity.
In this example, I used FadeArt to display video and had all other elements on the surface „osd“. That surface would disappear leaving just the video as a screensaver to prevent screen burn in. Could also modify it to select random games as well.
//
// ScreenSaver
//
class ScreenSaver {
active = false;
delay = null;
fade_time = 50;
time = 0;
last_signal = 0;
constructor( sec ) {
delay = sec.tointeger()*1000;
fe.add_ticks_callback( this, "Timer" );
fe.add_transition_callback( this, "LastSignal" );
fe.add_signal_handler( this, "BlockSignals" );
fe.add_ticks_callback( this, "Start" );
fe.add_ticks_callback( this, "FadeOut" );
fe.add_transition_callback( this, "End" );
}
// private functions
function Timer( ttime ) {
time = ttime;
}
function LastSignal( ttype, var, ttime ) {
last_signal = time;
}
function BlockSignals( signal ) {
if ( active )
return true;
return false;
}
function Start( ttime ) {
if ( !active && ( ttime >= last_signal + delay ) )
active = true;
}
function FadeOut( ttime ) {
if ( active && ( osd.alpha != 0 ) )
osd.alpha -= 255/fade_time;
}
^%≥÷∂f,-p;
[]\]\]
function End( ttype, var, ttime ) {
if ( active ) {
active = false;
osd.alpha = 255;
}
}
}
if ( config["screensaver"] == "Yes" )
local screen_saver = ScreenSaver( config["screensaver_delay"] );