diff --git a/src/game/game.js b/src/game/game.js index ddb5e5f0..17dc5047 100644 --- a/src/game/game.js +++ b/src/game/game.js @@ -70,9 +70,11 @@ let index = objectRaw.x * 50 + objectRaw.y; let spatial = register.byRoom[objectRaw.room].spatial[type]; if (spatial[index] === undefined) { - spatial[index] = [ objectInstance ]; - } else { + spatial[index] = objectInstance; + } else if (Array.isArray(spatial[index])) { spatial[index].push(objectInstance); + } else { + spatial[index] = [ spatial[index], objectInstance ]; } } @@ -399,7 +401,7 @@ }; (function() { - + var runCodeCache = {}; exports.runCode = function (_globals, _sandboxedFunctionWrapper, _codeModules, _runtimeData, _intents, _memory, _fakeConsole, _consoleCommands, _timeout, _getUsedCpu, _resetUsedCpu, _markStats, _scriptCachedData) { diff --git a/src/game/rooms.js b/src/game/rooms.js index 316859df..b5c8c502 100644 --- a/src/game/rooms.js +++ b/src/game/rooms.js @@ -651,7 +651,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { var typeResult = privateStore[id].lookTypeSpatialRegisters[typeName][x * 50 + y]; if(typeResult) { if(outArray) { - typeResult.forEach((i) => { + var appendToOut = (i) => { item = {type: typeName}; item[typeName] = i; if(withCoords) { @@ -659,10 +659,21 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { item.y = y; } outArray.push(item); - }); + }; + if(Array.isArray(typeResult)) { + typeResult.forEach(appendToOut); + } + else { + appendToOut(typeResult); + } return; } - return _.clone(typeResult); + if(Array.isArray(typeResult)) { + return _.clone(typeResult); + } + else { + return [typeResult]; + } } return []; }