This event triggers when a player moves in the room and comprises two parameters: one for the user object and the second for the position object, which can have various properties.
When a player moves freely in the room, the position will include the following properties: "x", "y", "z", and "facing".
If the player is sitting on an object, the position will have the following properties: "entity_id" and "anchor_ix".
Note: The position doesn't update in real-time. When a player makes a move, only the destination is logged, not the steps taken to get there. For instance, if the player moves from point A to D, only the position at point D will be logged, not the positions from A to D (i.e., "A, B, and C"). If you wish to log those intermediate positions, you'll need to implement your own mechanism to do so.
const { Highrise, Events } = require("highrise.sdk");
// Create a new instance of the Highrise class.
const bot = new Highrise({
Events: [
Events.Movements // Listen for movements.
]
});
// Listen for playerMove events.
bot.on("playerMove", (user, position) => {
// Check if the position has an x property.
if ('x' in position) {
// Log the position to the console.
console.log(`[MOVE]: ${user.username}:${user.id} - ${position.x}:${position.y}:${position.z}:${position.facing}`);
} else {
// Log the position to the console.
console.log(`[MOVE]: ${user.username}:${user.id} - ${position.entity_id}:${position.anchor_ix}`);
}
});
Go Back: Get Methods