Author Topic: script: random_game signal skips games randomed before.  (Read 1810 times)

popoklo

  • Full Member
  • ***
  • Posts: 50
    • View Profile
script: random_game signal skips games randomed before.
« on: November 26, 2017, 07:04:02 AM »
i made this script that the random game funtion does not show the same games which were randomed before.
In my mamelist with 2000 games there appear often the same games after random_game signal.

i tested this with 13 games in my fav_list. so please test it with 10 games or so to recreate the problem.
the problem:

sometimes the fe.signal(random_game) does not fire after a game is found. Its like the random_game signal gets lost.
the script fires the random_game signal so long till no match in the array rgames is found (that means the game was not randomed before)
Please watch the console.
press your random_game configed button as long as u can see the signal fires ("random signal is coming...and should now execute New transition:\n\n") but no new random game is selected and no transition is fired.

Code: [Select]

local rgames = [];

local mlist = fe.add_listbox(0,0,800,900);

fe.add_signal_handler( this, "on_signal" );
fe.add_transition_callback( this, "on_transition" );

function on_signal( sig )
{

switch (sig) {
    case "random_game":
    {
    print("random signal is coming...and should now execute New transition:\n\n");
    }
        return false;
}
}

function on_transition( ttype, var, ttime )
{
print("transition started...\n\n");

switch ( ttype )
{
case Transition.EndNavigation:
{
// print("EndNavigation \n");
if (rgames.len() >= fe.list.size) //clear the list if all games were randomed
{
rgames.clear();
print("cleared\n");
}

if (rgames.find(fe.list.index) == null)
{
rgames.push(fe.list.index);
print(fe.list.index + " not found...pushed\n");
} else
{
print(fe.list.index + " found...skipping------------\n");
fe.signal("random_game");
}

print("rgames size: " + rgames.len() + " / current listSize " + fe.list.size + " / current index: " + fe.list.index + "\n\n");
}        
}
}