var Utils; if (!Utils) { Utils = {}; } else if (typeof Utils != "object") { throw new Error("Utils.js: Utils already exists and is not an object."); } /** * Replacement for the "put then matchwait" cycle. * This function adds checking for roundtime and the type ahead queue * and repeats the command if necessary. * * Param command The command to send to the game * Param matches The previously setup matchtable */ Utils.matchPut = function(command, matches) { var wait = matches.match("...wait"); var queue = matches.match("Sorry, you may only type"); var match = 0; while (true) { // script.waitForRoundtime(); script.put(command); script.echo("Before matchwait"); match = matches.matchWait(); script.echo("After matchwait"); if (match == wait) { // script.waitForRoundtime(); // script.pause(0.5); } else if (match == queue) { script.pause(0.5); } else { return match; } } }