From c090e4911c92c00134542362aec43903f3739764 Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Wed, 18 Dec 2019 00:38:52 -0500 Subject: bugfixes --- socket.js | 6 +++--- space.js | 40 ++++++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/socket.js b/socket.js index 0e84222..29bab25 100644 --- a/socket.js +++ b/socket.js @@ -26,7 +26,6 @@ class retryws extends EventEmitter{ // a wrapper on ws that retries on failure } } - class Socket extends retryws { constructor(world='') { // Takes the name of the world, which can be an empty string. let loc = (world == '') ? '' : `/${world}`; @@ -59,8 +58,9 @@ class Socket extends retryws { throw "Too many characters to write"; } for (var i=0; i linenum.parseInt()); // list of included lines in the content let cont = chop(tile.content,16); let read = 0; //line of cont to read - for (let line=0; line++; line<8){ + for (let line=0; line<8; line++){ curline = line+8*tilerow; - if incl.includes(line){ + if (incl.includes(line)){ this.data[curline] += cont[read].split(''); read++; } else { - for (let i=0; i++; i<16) this.data[curline].push(' '); + for (let i=0; i<16; i++) this.data[curline].push(' '); } } } } this.towrite = function(charoffset){ // Does no splitting or anything like that. Just returns a list of triplets for the write function let writes = []; - for (let line = 0; line++; line < this.data.length) for (let chr = 0; chr++; chr< this[line].data.length){ - writes.push([line+Math.floor( (charoffset[0]+line)/8 ),line+Math.floor( (charoffset[1]+chr)/16 )],[ (charoffset[0]+line) % 8, (charoffset[1]+chr) % 16 ],this.data[line][chr]); + console.log(this.data.length); + for (line = 0; line < this.data.length; line++){ + console.log('boarlocueurgdaoecugd'); + } + for (let line = 0; line < this.data.length; line++) for (let chr = 0; chr< this.data[line].length; chr++){ + writes.push([[Math.floor( (charoffset[0]+line)/8 ),Math.floor( (charoffset[1]+chr)/16 )],[ (charoffset[0]+line) % 8, (charoffset[1]+chr) % 16 ],this.data[line][chr]]); } return writes; } this.tofile = function(filename){ - fs.writeFile(filename,this.data.map(row => replace(row,'','&').join('').replace(/\\|&/g, '\\$&')).join('\n'),(err)={console.log(err);}); + fs.writeFile(filename,this.data.map(row => replace(row,'','&').join('').replace(/\\|&/g, '\\$&')).join('\n')+'\n',(err)=>{console.log(err);}); }; this.fromfile = function(filename){ //Reads an external file into internal data fs.readFile(filename, (err, data) => { if (err) throw err; self.adhoc(data); - } + }); } this.adhoc = function(text){ this.data = text.split('\n').slice(0,-1).map(row => replace(row.replace(/\\(.)/g,'$1'.split(''),'&',''))); } - this.comb(other, func, offset){ + this.comb = function(other, func, offset){ offsety = offset[0]; offsetx = offset[1]; - for (let row = offset[0]; row++; row