interfaces query - wxyz-abcd/node-haxball GitHub Wiki

Query

This object only has static functions designed to query map features. Currently, the game should be active while using these functions.

  • getVertexIndexAtMapCoord(roomState: RoomState, point: Point, threshold: number): int

    Finds the index of the first Vertex that is near enough to any given point.

    Parameters:

    • roomState: RoomState: The state object to be queried. This object must come from inside a Room object. There are two ways of obtaining it:
      • Normal room state: room.state.
      • Extrapolated room state: room.stateExt.
    • point: Point: The point's coordinates. This is an object that should have the following keys:
      • x: number: The x coordinate.
      • y: number: The y coordinate. The coordinates should be converted into Haxball's coordinate system before being used here. You can use transformPixelCoordToMapCoord(x, y) and transformMapCoordToPixelCoord(x, y) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.
    • threshold: number: The maximum allowed distance to the point. The unit is not in pixels, but in Haxball's units. You can use transformPixelDistanceToMapDistance(distance) and transformMapDistanceToPixelDistance(distance) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.

    Return value: Index of the found Vertex, or -1 if it is not found.

  • getVertexAtMapCoord(roomState: RoomState, point: Point, threshold: number): Vertex

    Finds the first Vertex that is near enough to any given point.

    Parameters:

    • roomState: RoomState: The state object to be queried. This object must come from inside a Room object. There are two ways of obtaining it:
      • Normal room state: room.state.
      • Extrapolated room state: room.stateExt.
    • point: Point: The point's coordinates. This is an object that should have the following keys:
      • x: number: The x coordinate.
      • y: number: The y coordinate. The coordinates should be converted into Haxball's coordinate system before being used here. You can use transformPixelCoordToMapCoord(x, y) and transformMapCoordToPixelCoord(x, y) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.
    • threshold: number: The maximum allowed distance to the point. The unit is not in pixels, but in Haxball's units. You can use transformPixelDistanceToMapDistance(distance) and transformMapDistanceToPixelDistance(distance) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.

    Return value: The found Vertex, or undefined if it is not found.

  • getSegmentIndexAtMapCoord(roomState: RoomState, point: Point, threshold: number): int

    Finds the index of the first Segment that is near enough to any given point.

    Parameters:

    • roomState: RoomState: The state object to be queried. This object must come from inside a Room object. There are two ways of obtaining it:
      • Normal room state: room.state.
      • Extrapolated room state: room.stateExt.
    • point: Point: The point's coordinates. This is an object that should have the following keys:
      • x: number: The x coordinate.
      • y: number: The y coordinate. The coordinates should be converted into Haxball's coordinate system before being used here. You can use transformPixelCoordToMapCoord(x, y) and transformMapCoordToPixelCoord(x, y) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.
    • threshold: number: The maximum allowed distance to the point. The unit is not in pixels, but in Haxball's units. You can use transformPixelDistanceToMapDistance(distance) and transformMapDistanceToPixelDistance(distance) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.

    Return value: Index of the found Segment, or -1 if it is not found.

  • getSegmentAtMapCoord(roomState: RoomState, point: Point, threshold: number): Segment

    Finds the first Segment that is near enough to any given point.

    Parameters:

    • roomState: RoomState: The state object to be queried. This object must come from inside a Room object. There are two ways of obtaining it:
      • Normal room state: room.state.
      • Extrapolated room state: room.stateExt.
    • point: Point: The point's coordinates. This is an object that should have the following keys:
      • x: number: The x coordinate.
      • y: number: The y coordinate. The coordinates should be converted into Haxball's coordinate system before being used here. You can use transformPixelCoordToMapCoord(x, y) and transformMapCoordToPixelCoord(x, y) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.
    • threshold: number: The maximum allowed distance to the point. The unit is not in pixels, but in Haxball's units. You can use transformPixelDistanceToMapDistance(distance) and transformMapDistanceToPixelDistance(distance) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.

    Return value: The found Segment, or -1 if it is not found.

  • getGoalIndexAtMapCoord(roomState: RoomState, point: Point, threshold: number): int

    Finds the first Goal that is near enough to any given point.

    Parameters:

    • roomState: RoomState: The state object to be queried. This object must come from inside a Room object. There are two ways of obtaining it:
      • Normal room state: room.state.
      • Extrapolated room state: room.stateExt.
    • point: Point: The point's coordinates. This is an object that should have the following keys:
      • x: number: The x coordinate.
      • y: number: The y coordinate. The coordinates should be converted into Haxball's coordinate system before being used here. You can use transformPixelCoordToMapCoord(x, y) and transformMapCoordToPixelCoord(x, y) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.
    • threshold: number: The maximum allowed distance to the point. The unit is not in pixels, but in Haxball's units. You can use transformPixelDistanceToMapDistance(distance) and transformMapDistanceToPixelDistance(distance) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.

    Return value: The found Goal, or undefined if it is not found.

  • getGoalAtMapCoord(roomState: RoomState, point: Point, threshold: number): Goal

    Finds the first Goal that is near enough to any given point.

    Parameters:

    • roomState: RoomState: The state object to be queried. This object must come from inside a Room object. There are two ways of obtaining it:
      • Normal room state: room.state.
      • Extrapolated room state: room.stateExt.
    • point: Point: The point's coordinates. This is an object that should have the following keys:
      • x: number: The x coordinate.
      • y: number: The y coordinate. The coordinates should be converted into Haxball's coordinate system before being used here. You can use transformPixelCoordToMapCoord(x, y) and transformMapCoordToPixelCoord(x, y) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.
    • threshold: number: The maximum allowed distance to the point. The unit is not in pixels, but in Haxball's units. You can use transformPixelDistanceToMapDistance(distance) and transformMapDistanceToPixelDistance(distance) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.

    Return value: The found Goal, or undefined if it is not found.

  • getPlaneIndexAtMapCoord(roomState: RoomState, point: Point, threshold: number): int

    Finds the first Plane that is near enough to any given point.

    Parameters:

    • roomState: RoomState: The state object to be queried. This object must come from inside a Room object. There are two ways of obtaining it:
      • Normal room state: room.state.
      • Extrapolated room state: room.stateExt.
    • point: Point: The point's coordinates. This is an object that should have the following keys:
      • x: number: The x coordinate.
      • y: number: The y coordinate. The coordinates should be converted into Haxball's coordinate system before being used here. You can use transformPixelCoordToMapCoord(x, y) and transformMapCoordToPixelCoord(x, y) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.
    • threshold: number: The maximum allowed distance to the point. The unit is not in pixels, but in Haxball's units. You can use transformPixelDistanceToMapDistance(distance) and transformMapDistanceToPixelDistance(distance) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.

    Return value: The found Plane, or undefined if it is not found.

  • getPlaneAtMapCoord(roomState: RoomState, point: Point, threshold: number): Plane

    Finds the first Plane that is near enough to any given point.

    Parameters:

    • roomState: RoomState: The state object to be queried. This object must come from inside a Room object. There are two ways of obtaining it:
      • Normal room state: room.state.
      • Extrapolated room state: room.stateExt.
    • point: Point: The point's coordinates. This is an object that should have the following keys:
      • x: number: The x coordinate.
      • y: number: The y coordinate. The coordinates should be converted into Haxball's coordinate system before being used here. You can use transformPixelCoordToMapCoord(x, y) and transformMapCoordToPixelCoord(x, y) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.
    • threshold: number: The maximum allowed distance to the point. The unit is not in pixels, but in Haxball's units. You can use transformPixelDistanceToMapDistance(distance) and transformMapDistanceToPixelDistance(distance) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.

    Return value: The found Plane, or undefined if it is not found.

  • getJointIndexAtMapCoord(roomState: RoomState, point: Point, threshold: number): int

    Finds the first Joint that is near enough to any given point.

    Parameters:

    • roomState: RoomState: The state object to be queried. This object must come from inside a Room object. There are two ways of obtaining it:
      • Normal room state: room.state.
      • Extrapolated room state: room.stateExt.
    • point: Point: The point's coordinates. This is an object that should have the following keys:
      • x: number: The x coordinate.
      • y: number: The y coordinate. The coordinates should be converted into Haxball's coordinate system before being used here. You can use transformPixelCoordToMapCoord(x, y) and transformMapCoordToPixelCoord(x, y) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.
    • threshold: number: The maximum allowed distance to the point. The unit is not in pixels, but in Haxball's units. You can use transformPixelDistanceToMapDistance(distance) and transformMapDistanceToPixelDistance(distance) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.

    Return value: The found Joint, or undefined if it is not found.

  • getJointAtMapCoord(roomState: RoomState, point: Point, threshold: number): Joint

    Finds the first Joint that is near enough to any given point.

    Parameters:

    • roomState: RoomState: The state object to be queried. This object must come from inside a Room object. There are two ways of obtaining it:
      • Normal room state: room.state.
      • Extrapolated room state: room.stateExt.
    • point: Point: The point's coordinates. This is an object that should have the following keys:
      • x: number: The x coordinate.
      • y: number: The y coordinate. The coordinates should be converted into Haxball's coordinate system before being used here. You can use transformPixelCoordToMapCoord(x, y) and transformMapCoordToPixelCoord(x, y) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.
    • threshold: number: The maximum allowed distance to the point. The unit is not in pixels, but in Haxball's units. You can use transformPixelDistanceToMapDistance(distance) and transformMapDistanceToPixelDistance(distance) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.

    Return value: The found Joint, or undefined if it is not found.

  • getDiscIndexAtMapCoord(roomState: RoomState, point: Point): int

    Finds the index of the first Disc that includes any given point.

    Parameters:

    • roomState: RoomState: The state object to be queried. This object must come from inside a Room object. There are two ways of obtaining it:
      • Normal room state: room.state.
      • Extrapolated room state: room.stateExt.
    • point: Point: The point's coordinates. This is an object that should have the following keys:
      • x: number: The x coordinate.
      • y: number: The y coordinate. The coordinates should be converted into Haxball's coordinate system before being used here. You can use transformPixelCoordToMapCoord(x, y) and transformMapCoordToPixelCoord(x, y) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.

    Return value: Index of the found Disc, or -1 if it is not found.

  • getDiscAtMapCoord(roomState: RoomState, point: Point): Disc

    Finds the first Disc that includes any given point.

    Parameters:

    • roomState: RoomState: The state object to be queried. This object must come from inside a Room object. There are two ways of obtaining it:
      • Normal room state: room.state.
      • Extrapolated room state: room.stateExt.
    • point: Point: The point's coordinates. This is an object that should have the following keys:
      • x: number: The x coordinate.
      • y: number: The y coordinate. The coordinates should be converted into Haxball's coordinate system before being used here. You can use transformPixelCoordToMapCoord(x, y) and transformMapCoordToPixelCoord(x, y) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.

    Return value: The found Disc, or undefined if it is not found.

  • getSpawnPointIndexAtMapCoord(roomState: RoomState, point: Point, threshold: number): [spawnPointIndex: int, teamId: int]

    Finds the first spawn point that is near enough to any given point.

    Parameters:

    • roomState: RoomState: The state object to be queried. This object must come from inside a Room object. There are two ways of obtaining it:
      • Normal room state: room.state.
      • Extrapolated room state: room.stateExt.
    • point: Point: The point's coordinates. This is an object that should have the following keys:
      • x: number: The x coordinate.
      • y: number: The y coordinate. The coordinates should be converted into Haxball's coordinate system before being used here. You can use transformPixelCoordToMapCoord(x, y) and transformMapCoordToPixelCoord(x, y) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.
    • threshold: number: The maximum allowed distance to the point. The unit is not in pixels, but in Haxball's units. You can use transformPixelDistanceToMapDistance(distance) and transformMapDistanceToPixelDistance(distance) functions defined in both DefaultRenderer and SandboxRenderer for transformations between Haxball's and browser's coordinate systems.

    Return value: The found spawn point's index and team id, or [-1, -1] if it is not found.

⚠️ **GitHub.com Fallback** ⚠️