From 7bc933123d33f97d430e8a3770037ec89988f704 Mon Sep 17 00:00:00 2001 From: Bob S Date: Fri, 21 Jul 2023 17:07:05 -0400 Subject: [PATCH 1/3] Create lookForNearby.js --- .../JavaScript/RoomPosition/lookForNearby.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/prototypes/JavaScript/RoomPosition/lookForNearby.js diff --git a/src/prototypes/JavaScript/RoomPosition/lookForNearby.js b/src/prototypes/JavaScript/RoomPosition/lookForNearby.js new file mode 100644 index 0000000..bf53a9b --- /dev/null +++ b/src/prototypes/JavaScript/RoomPosition/lookForNearby.js @@ -0,0 +1,19 @@ +/** + * warinternal's Original Code -- + * Shorthand LOOK_* around a room position modified by Shibdib from a roomObject to roomPosition + * + * @param {string} lookFor - LOOK_* constant + * @param {boolean} asArray - Return as array bool + * @param {number} range - Range to look + * @returns {object} Returns an object/array of the results + */ +RoomPosition.prototype.lookForNearby = function (lookFor, asArray = true, range = 1) { + return Game.rooms[this.roomName].lookForAtArea( + lookFor, + Math.max(0, this.y - range), + Math.max(0, this.x - range), + Math.min(49, this.y + range), + Math.min(49, this.x + range), + asArray + ); +}; From 3baaf81ffa145d526bea0e5ea87211997564c180 Mon Sep 17 00:00:00 2001 From: Bob S Date: Fri, 21 Jul 2023 17:09:32 -0400 Subject: [PATCH 2/3] add lookNearby --- .../JavaScript/RoomPosition/lookForNearby.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/prototypes/JavaScript/RoomPosition/lookForNearby.js b/src/prototypes/JavaScript/RoomPosition/lookForNearby.js index bf53a9b..601d48f 100644 --- a/src/prototypes/JavaScript/RoomPosition/lookForNearby.js +++ b/src/prototypes/JavaScript/RoomPosition/lookForNearby.js @@ -1,6 +1,6 @@ /** * warinternal's Original Code -- - * Shorthand LOOK_* around a room position modified by Shibdib from a roomObject to roomPosition + * Shorthand for lookForAtArea around a room position modified by Shibdib from a roomObject to roomPosition * * @param {string} lookFor - LOOK_* constant * @param {boolean} asArray - Return as array bool @@ -17,3 +17,21 @@ RoomPosition.prototype.lookForNearby = function (lookFor, asArray = true, range asArray ); }; + +/** + * warinternal's Original Code -- + * Shorthand for lookAtArea around a room position modified by Shibdib from a roomObject to roomPosition + * + * @param {boolean} asArray - Return as array bool + * @param {number} range - Range to look + * @returns {object} Returns an object/array of the results + */ +RoomPosition.prototype.lookNearby = function (asArray, range = 1) { + return Game.rooms[this.roomName].lookAtArea( + Math.max(0, this.y - range), + Math.max(0, this.x - range), + Math.min(49, this.y + range), + Math.min(49, this.x + range), + asArray + ); +}; From b54cdf7130d3328818197af9228ead8be7acc55a Mon Sep 17 00:00:00 2001 From: Bob S Date: Fri, 21 Jul 2023 17:10:57 -0400 Subject: [PATCH 3/3] Add comment --- src/prototypes/JavaScript/RoomPosition/lookForNearby.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/prototypes/JavaScript/RoomPosition/lookForNearby.js b/src/prototypes/JavaScript/RoomPosition/lookForNearby.js index 601d48f..150961a 100644 --- a/src/prototypes/JavaScript/RoomPosition/lookForNearby.js +++ b/src/prototypes/JavaScript/RoomPosition/lookForNearby.js @@ -1,3 +1,5 @@ +// Modified warinternals old roomObject submission to fall under pos as that just made more sense continuinty wise. + /** * warinternal's Original Code -- * Shorthand for lookForAtArea around a room position modified by Shibdib from a roomObject to roomPosition