25
« on: September 04, 2018, 04:19:15 PM »
class Random
{
m_config = null;
m_last_rand = 0;
m_rand_ms = 0;
constructor() {
m_config = fe.get_config();
m_rand_ms = 1000 * m_config["rand_s"].tointeger();
if (!fe.nv.rawin( "Random" ))
fe.nv.rawset( "Random", false);
fe.add_ticks_callback( this, "on_tick" );
fe.add_transition_callback( this, "on_transition" );
}
function on_tick( ttime )
{
if ( ttime - m_last_rand > 10000 )
{
local roll = 1.0 * rand() / RAND_MAX;
roll = ( roll * fe.displays.len() );
fe.set_display( roll );
m_last_rand = ttime;
fe.nv[ "Random" ] = true;