Skip to content
samuri51 edited this page Apr 11, 2013 · 2 revisions
1. create global variable at top of script
example:

var snagCounter = 0; //initialize at zero

2. create global flag variable

var flag = false; //assume were not autoboping, booleans can be either true or false

3. create command inside speak event, something like

if(data.text == '/autobop')
{
	bot.speak('lets begin autobopping : ) ' + ' 4 songs of autobop left');

    //set flag to true	
	flag = true;
}

in new song event increment the counter, and put a condition on it
something like

if(flag == true) //if flag is true keep going with this
{
	if(snagCounter == 4) //if we made it this far and we haven't maxed out our counter
	{
		bot.speak('i has finished with meh autobops xD');
		snagCounter = 0;
		flag = false; //if goal has been reached, reset counter, set flag to false
	}
	else //else do this
	{
		bot.speak('you still have ' + (4 - snagCounter) + ' left of autobop'); //say something(optional)
		snagCounter += 1; //increment by one
		bot.bop(); //cause bot to bop
	}
}	
Clone this wiki locally