game.js
// Pushes text to the battle log
Pushes text to the battle log
Pushes text to the battle log
function updateOutput(newText) {
	sleep(750);
	if (newText.length > 55) {
		var found = false;
		for(var i=50;i<56;i++) {
			if(newText[i] == " ") {
				newText = newText.substr(0,i) + "\n    " + newText.substr(i+1,newText.length - 1);
				found = true;
				break;
			}
		} if (!found) {
			newText = newText.substr(0,54) + "-\n    " + newText.substr(54,newText.length - 1);
		}
	}
	output.setText(output.text + "\n" + newText);
	var lines = output.text.split("\n");
	while (lines.length > 7) {
		lines.splice(0,1);
	}
	output.text = lines.join("\n");
	console.log(newText);
}
function updateOutput ( newText ) { sleep ( 750 ) ; if ( newText . length > 55 ) { var found = false ; for ( var i = 50 ; i < 56 ; i ++ ) { if ( newText [ i ] == " " ) { newText = newText . substr ( 0 , i ) + "\n    " + newText . substr ( i + 1 , newText . length - 1 ) ; found = true ; break ; } } if ( ! found ) { newText = newText . substr ( 0 , 54 ) + "-\n    " + newText . substr ( 54 , newText . length - 1 ) ; } } output . setText ( output . text + "\n" + newText ) ; var lines = output . text . split ( "\n" ) ; while ( lines . length > 7 ) { lines . splice ( 0 , 1 ) ; } output . text = lines . join ( "\n" ) ; console . log ( newText ) ; }
Pushes text to the battle log
Pushes text to the battle log
// waits for a sec // tries to break the text to a new line if it's too long // Pushes the oldest line out of the log