Skip to content

Add roomPosition lookFor/lookAt #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/prototypes/JavaScript/RoomPosition/lookForNearby.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 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
*
* @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
);
};

/**
* 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
);
};