samuri51 / chillybot

a turntable bot created by a moderator of straight_chillin11
12 stars 12 forks source link

Bug #43

Closed ghost closed 11 years ago

ghost commented 11 years ago

I changed my code for Chillster to fit the Turntable.fm rules of having bots only auto-dj when there are 2 other djs on stage. There's a bug where the bot automatically jumps down from stage as soon as he gets on stage.

//governs whether the bot gets on or off the stage automatically (autodjing)
global.autoDjing = function ()
{
    if (autoDjingTimer != null)
    {
        clearTimeout(autoDjingTimer);
        autoDjingTimer = null;
    }

    autoDjingTimer = setTimeout(function ()
    {
        var isBotAlreadyOnStage = currentDjs.indexOf(USERID);

        if (isBotAlreadyOnStage == -1) //if the bot is not already on stage
        {
            if (currentDjs.length >= 2 && currentDjs.length <= whenToGetOnStage && queueList.length === 0)
            {
                if (getonstage === true && vipList.length === 0 && refreshList.length === 0)
                {
                    bot.addDj();
                }
            }
        }
        else //else it is on stage
        {
            if (currentDjs.length >= whenToGetOffStage && getonstage === true && checkWhoIsDj != USERID)
            {
                bot.remDj();
            }
        }
    }, 1000 * 10); //delay for 10 seconds        
};
samuri51 commented 11 years ago

you need to change whenToGetOnStage in the setup to 2 and whenToGetOffStage to something greater than 3, because the bot counts as one person so if its set to three it gets on stage when theres two people, and then evaluates how many dj's are on stage, sees that there are now 3 people on stage and immediately gets off

samuri51 commented 11 years ago

you would also need to comment out the bot.addDj() in the no song event, since itll still hop on stage when no ones playing anything

ghost commented 11 years ago

thanks :)