Skip to content

Instantly share code, notes, and snippets.

@UltraSabreman
Created November 20, 2015 02:13
Show Gist options
  • Save UltraSabreman/90e99a394aab7a8dc453 to your computer and use it in GitHub Desktop.
Save UltraSabreman/90e99a394aab7a8dc453 to your computer and use it in GitHub Desktop.
Some random js bs for your world of text
//window.w.doGoToCoord(y, x);
var SpamClass = (function() {
var spamID = -1;
spam = function(tsX, tsY, width, heigth, str) {
spamID = setInterval(tsX, tsY, width, heigth, str, 1000);
}
stopSpam = function() {
if (spamID != -1) {
clearInterval(spamID);
}
}
testFill = function(tsX, tsY, width, heigth, str) {
var theWorld = window.w;
var teX = tsX + width;
var teY = tsY + heigth;
var charsWidth = theWorld._config.tileWidth() / theWorld._config.charWidth();
var charsHeight = theWorld._config.tileHeight() / theWorld._config.charHeight();
var Word = str;
var localEdits = [];
var stringIndex = 0;
var timestamp = new Date().getTime();
for (ty = tsY; ty < teY; ty++) {
for (tx = tsX; tx < teX; tx++) {
var theTile = theWorld.getTile(ty,tx);
if (!theTile || !Permissions.can_edit_tile(theWorld.userModel, theWorld.worldModel, theTile)) continue;
for (y = 0; y < charsHeight; y++) {
for (x = 0; x < charsWidth; x++) {
theTile.tellEdit(y, x, Word[stringIndex], timestamp);
localEdits.push([ty, tx, y, x, timestamp, Word[stringIndex], "Email me before scripting"]);
stringIndex = (stringIndex + 1) % Word.length;
}
}
jQuery.ajax({
type: "POST",
url: window.location.pathname,
data: {
edits: JSON.stringify(localEdits)
},
success: function(data, status, shit) {
console.info(status);
},
dataType: "json",
error: function(data, status, shit) {
console.error(status);
}
});
localEdits = [];
}
}
};
});
SpamClass();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment