remoteMap prescan spawn and also scan newly generated chunks

This commit is contained in:
Danielv123 committed 2018-03-26 16:11:56 +02:00
1 parent 2ab163ab68
commit 0aa25544b0
4 files changed
+54 -18

No files matched your search

+6 -6
View File
@@ -13,8 +13,8 @@ class remoteMap {
// initialize chunk database
this.chunkMap = new chunkStore(this.config.unique, 64, "./database/chunkStore/");
this.chunkMap.onEntityChange(entity => {
console.log("Entity changed: ")
console.log(entity);
this.messageInterface("Entity changed: ")
this.messageInterface(entity);
// check valid coordinates (dunno what could go wrong, but can never be too sure)
if(entity && entity.x !== undefined && !isNaN(Number(entity.x)) && entity.y !== undefined && !isNaN(Number(entity.y))){
this.socket.emit("sendEntity", entity);
@@ -31,7 +31,7 @@ class remoteMap {
},10000);
});
this.socket.on("getChunk", req => {
console.log("getChunk is not supported!");
this.messageInterface("getChunk is not supported!");
/*this.chunkMap.getChunk(req.x, req.y).then(chunk => {
chunk.requesterID = req.requesterID;
this.socket.emit("sendChunk", chunk);
@@ -54,7 +54,7 @@ class remoteMap {
// both placing and deleting entities via the web interface
this.socket.on("placeEntity", req => {
// game.player.surface.create_entity{name="small-ship-wreck", position={game.player.position.x-2, game.player.position.y+1}, direction=..., force=...}
console.log("placing "+JSON.stringify(req));
this.messageInterface("placing "+JSON.stringify(req));
if(req.name && typeof req.name == "string" && req.position && !isNaN(Number(req.position.x)) && !isNaN(Number(req.position.y))){
if(req.name == "deleted"){ // {{'+req.position.x+','+req.position.y+'},{'+req.position.x+','+req.position.y+'}}
this.messageInterface('/silent-command local toDelete = game.surfaces[1].find_entities({{'+req.position.x+','+req.position.y+'},{'+(req.position.x+1)+','+(req.position.y+1)+'}}) for i, entity in pairs(toDelete) do entity.die() end');
@@ -96,8 +96,8 @@ class remoteMap {
// express-transport-belt,-35.5,-14.5,[...]
data = data.split(",");
if(data && data[0] == undefined){
console.log("empty: ");
console.log(data);
this.messageInterface("empty: ");
this.messageInterface(data);
return
}
let name = data[0];