Created
June 3, 2015 18:40
-
-
Save AnneFrankTP/84fa05b684d5fdc797a9 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 Move Spec | |
// @version 0.1 | |
// @description Use arrow keys to move the camera while spectating. Shift doubles the speed, ctrl halves it | |
// @include http://tagpro-*.koalabeast.com:* | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js | |
// @author Some Ball -1 | |
// ==/UserScript== | |
$(function() { | |
tagpro.ready(function() { | |
//change this number to modify the speed of the camera movement | |
//2 is on the slower end, 5 is decent, 10 is pretty fast, play around with it | |
var jumps = 5; //default is 5 | |
var shift = false; | |
var ctrl = false; | |
function begin() | |
{ | |
var clearable = -1; | |
var adds = { | |
37: 0, | |
38: 0, | |
39: 0, | |
40: 0, | |
}; | |
function move() | |
{ | |
tagpro.viewPort.source.x += (adds[39]-adds[37])*jumps*(shift?2:1)*(ctrl?.5:1); | |
tagpro.viewPort.source.y += (adds[40]-adds[38])*jumps*(shift?2:1)*(ctrl?.5:1); | |
} | |
$(document).keydown(function(key) { //37 <, 38 ^, 39 >, 40 down | |
shift = key.shiftKey; | |
ctrl = key.ctrlKey; | |
if(key.which>=37 && key.which<=40) | |
{ | |
if(tagpro.viewPort.followPlayer) | |
{ | |
tagpro.viewPort.followPlayer = false; | |
tagpro.viewPort.source = {x: tagpro.viewPort.source.x, | |
y: tagpro.viewPort.source.y}; | |
} | |
adds[key.which] = 1; | |
if(clearable==-1) //no key was previously pressed | |
{ | |
clearable = setInterval(move, 15); | |
} | |
} | |
}); | |
$(document).keyup(function(key) { | |
shift = key.shiftKey; | |
ctrl = key.ctrlKey; | |
if(key.which>=37 && key.which<=40) | |
{ | |
adds[key.which] = 0; | |
if(adds[37]+adds[38]+adds[39]+adds[40]==0) //no keys still pressed | |
{ | |
clearInterval(clearable); | |
clearable = -1; | |
} | |
} | |
}); | |
} | |
setTimeout(function() { | |
if(tagpro.spectator) | |
{ | |
begin(); | |
} | |
}, 750); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment