diff --git a/lib/chunkStore.js b/lib/chunkStore.js index c3d9e9ab..add6ed2e 100644 --- a/lib/chunkStore.js +++ b/lib/chunkStore.js @@ -15,9 +15,9 @@ module.exports = class chunkStore { } setEntity(x/**{number}*/, y/**{number}*/, newEntity/**{object}*/){ return new Promise((resolve, reject) => { - var localX = Math.round(x % this.chunkSize); + var localX = x > 0 ? Math.round(x % this.chunkSize) : Math.round(x % this.chunkSize)-64; x = Math.floor(Math.round(x)/this.chunkSize); - var localY = Math.round(y % this.chunkSize); + var localY = y > 0 ? Math.round(y % this.chunkSize) : Math.round(x % this.chunkSize)-64; y = Math.floor(Math.round(y)/this.chunkSize); this.getChunk(x,y).then(chunk => { @@ -43,7 +43,7 @@ module.exports = class chunkStore { setChunk(x, y, chunk){ return new Promise((resolve, reject) => { mkdirp(this.path+this.name+"/"+x).then(() => { - fs.writeFile(this.path+this.name+"/"+x+"/"+y, JSON.stringify(chunk), function(err){ + fs.writeFile(this.path+this.name+"/"+x+"/"+y, JSON.stringify(chunk, null, 4), function(err){ if(err) { reject(err); } else resolve(); diff --git a/sharedPlugins/remoteMap/control.lua b/sharedPlugins/remoteMap/control.lua index 80465964..98959d7e 100644 --- a/sharedPlugins/remoteMap/control.lua +++ b/sharedPlugins/remoteMap/control.lua @@ -50,19 +50,14 @@ function writeout_objects(surface, area) --if my_client_id ~= 1 then return end header = "objects "..area.left_top.x..","..area.left_top.y..";"..area.right_bottom.x..","..area.right_bottom.y..": " line = '' - lines={} for idx, ent in pairs(surface.find_entities(area)) do if area.left_top.x <= ent.position.x and ent.position.x < area.right_bottom.x and area.left_top.y <= ent.position.y and ent.position.y < area.right_bottom.y then if ent.prototype.collision_mask ~= nil and ent.prototype.collision_mask['player-layer'] then - line=line..","..ent.name.." "..ent.position.x.." "..ent.position.y - if idx % 100 == 0 then - table.insert(lines,line) - line='' - end + line = line .. ent.name.." "..ent.position.x.." "..ent.position.y.."\n" end end end - table.insert(lines,line) + write_file(line) --write_file(header..table.concat(lines,"").."\n") --write_file(table.concat(lines,"").."\n") line=nil diff --git a/static/remoteMap.html b/static/remoteMap.html index 36f68e7d..5f6f0569 100644 --- a/static/remoteMap.html +++ b/static/remoteMap.html @@ -9,7 +9,8 @@ <%- include("sidebar.html") %>