Created
November 26, 2017 23:17
-
-
Save MarksCode/df034aa55e9542d5a19a924e76196569 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name TagPro Stop Test | |
// @version 0.1 | |
// @include http://tagpro-maptest.koalabeast.com:* | |
// @include http://tangent.jukejuice.com:* | |
// @include http://*.newcompte.fr:* | |
// @author Cap | |
// ==/UserScript== | |
tagpro.ready(function() { | |
setTimeout(function() { | |
run(); | |
}, 5000) | |
}); | |
var data = []; | |
var x = 0; | |
var r = []; | |
for (var i = 100; i < 1000; i++) { | |
r.push(i); | |
} | |
function run() { | |
var t = time(); | |
t.then(function(val) { | |
x++; | |
data.push(val) | |
if (x < r.length) { | |
run(); | |
} else { | |
console.log(data); | |
tagpro.sendKeyPress("left", true); | |
tagpro.sendKeyPress("right", true); | |
return; | |
} | |
}) | |
} | |
function time() { | |
return new Promise((resolve, reject) => { | |
var timeElapsed = 0; | |
var s = r[x]; | |
var startedStopping = false; | |
var v = 0; | |
var start = null; | |
tagpro.sendKeyPress("left", true); | |
tagpro.sendKeyPress("right", false); | |
var a = setInterval(function() { | |
timeElapsed++; | |
if (timeElapsed > s) { | |
if (!startedStopping) { | |
tagpro.sendKeyPress("left", false); | |
tagpro.sendKeyPress("right", true); | |
start = new Date().getTime(); | |
v = tagpro.players[tagpro.playerId].lx; | |
startedStopping = true; | |
} | |
if (Math.abs(tagpro.players[tagpro.playerId].lx) < 0.2) { | |
var end = new Date().getTime(); | |
var time = end - start; | |
clearInterval(a); | |
console.log(v, time); | |
tagpro.sendKeyPress("left", true); | |
tagpro.sendKeyPress("right", true); | |
setInterval(function() { | |
resolve([v, time]) | |
}, 5000) | |
} | |
} | |
}, 2); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment