From c24c6ad39f2e80f52d3312c26b590be60ae1ea27 Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Wed, 15 Jul 2015 19:56:01 +0200 Subject: [PATCH] Fixes chess game (pieces were dieing as soon as you dropped them) --- examples/entityScripts/chessPiece.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/entityScripts/chessPiece.js b/examples/entityScripts/chessPiece.js index b6dfca9efd..24ba7b33e8 100644 --- a/examples/entityScripts/chessPiece.js +++ b/examples/entityScripts/chessPiece.js @@ -130,10 +130,10 @@ var others = Entities.findEntities(this.properties.position, this.properties.dimensions.y); for (var i = 0; i < others.length; i++) { - var piece = others[i]; + var pieceID = others[i]; - if (piece.id != this.entityID) { - var properties = Entities.getEntityProperties(piece); + if (pieceID != this.entityID) { + var properties = Entities.getEntityProperties(pieceID); var isWhite = properties.modelURL.search("White") !== -1; var type = (properties.modelURL.search("King") !== -1) ? 4 : @@ -147,7 +147,7 @@ if (myPos.i === piecePos.i && myPos.j === piecePos.j && type !== -2) { var position = this.getAbsolutePosition((isWhite) ? { i: type, j: -1 } : { i: 7 - type, j: 8 }, properties.dimensions.y / 2.0); - Entities.editEntity(piece, { + Entities.editEntity(pieceID, { position: position }); break;