Trying to make a way to check certain conditions for a win

Okay, so I’m still getting stuck at the same place. The flag works, it only starts checking after I click the button, but stopCheck() never gets called.

Says stopped is undefined.

Defined now, but still nothing.

ok, I did a bit of debugging and I think I found the main issue.

The coordinates, for some weird reason, keep changing of a very tiny value. It seems that the physics engine doesn’t put an object on rest, but keeps calculating its position.

For example lastPost.z = -2.7531046867370605 and diePos.z = -2.7531025409698486
As you see after the first 5 digits, the numbers are different. So I would reintroduce the toDecimal function you were using, but I’d increase the precision:

CheckRoll.prototype.toDecimal = function(num)
{
    return Math.round(num * 1000) / 1000;
};

Also, remove the line 71 at the end of the check function or the check will not be executed again every 3 seconds:

this.manager.script.gameManager.removedCoins = false;

I hope this will be the good one :slight_smile:

Anyway, I strongly suggest you to use more the step by step debugger of your browser so you can see what is going on.

Seems to work better after re-adding the toDecimal, small problem on first roll which I can’t make sense of is the update counts to 3, 3 times before actually checking.

I have been using this, the only issue I have with it is 90% of the time I end up in the engine code and it takes 20 minutes to get back out of it going step by step. It also seems to stall any update counter that’s currently going. I’ve started a roll, and after stepping through the break point and getting back to running the game the counter will be at some number it’s not supposed to reach.

For some reason the stopped boolean is staying false when it should get set to true.

dice[i].stopped = true;

In the debugger it says stopped is false after stepping to the next line.

Seems to work when I have an active break point in the debugger, the instant I remove it or stop using the debugger, it stops again.

Got it, added an else statement to stopCheck to run check.

CheckRoll.prototype.stopCheck = function()
{
    //If all dice have stopped, get their values and stop checking in update
    if(dice[0].stopped === true && dice[1].stopped === true && dice[2].stopped === true && dice[3].stopped === true && dice[4].stopped === true)
    {
        this.manager.script.gameManager.removedCoins = false;
        this.stop = false;
        this.checkResult();
    }
    else
    {
        this.check();
    }
};

Now for the odd straights.

Got the straights. Annoying math stuff done yay! :grin:
Thanks for all the help, and apologies for all the seemingly unnecessary posts and questions. I have a habit of “vocalizing” my problem and solving it a short while later.

1 Like