Skip to content

Instantly share code, notes, and snippets.

@MarksCode
Created November 26, 2017 23:17
Show Gist options
  • Save MarksCode/df034aa55e9542d5a19a924e76196569 to your computer and use it in GitHub Desktop.
Save MarksCode/df034aa55e9542d5a19a924e76196569 to your computer and use it in GitHub Desktop.
// ==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