Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Conversation

WillowsDad
Copy link
Contributor

    For the given item ID(s), returns the first inventory slot index that the item exists in.
    e.g. [1, 1, 2, 3, 3, 3, 4, 4, 4, 4] -> [0, 2, 3, 6]
    Args:
        item_id: The item ID to search for (an single ID, or list of IDs).
    Returns:
        The first inventory slot index that the item exists in for each unique item ID.
        If a single item ID is provided, returns an integer.
        If no matching item ID is found, returns -1.

        For the given item ID(s), returns the first inventory slot index that the item exists in.
        e.g. [1, 1, 2, 3, 3, 3, 4, 4, 4, 4] -> [0, 2, 3, 6]
        Args:
            item_id: The item ID to search for (an single ID, or list of IDs).
        Returns:
            The first inventory slot index that the item exists in for each unique item ID.
            If a single item ID is provided, returns an integer.
            If no matching item ID is found, returns -1.
        """
        Gets the distance between the object and it's Rectangle parent left edge.
        Useful for sorting lists of RuneLiteObjects.
        Returns:
            The distance from the point to the center of the object.
        Note:
            Only use this if you're sorting a list of RuneLiteObjects that are contained in the same Rectangle.
        """
@WillowsDad WillowsDad changed the title add "get_first_indice()" method to morg api add "get_first_indice()" method to morg api and distance calculation to geometry.py Apr 21, 2023
@kelltom
Copy link
Owner

kelltom commented Apr 22, 2023

Hey, I'm curious about what the use cases are for sorting RL objects from left to right.

Wondering if maybe we can make distance calculations way more robust (e.g., allow for sorting by passing a point instead of making functions for each possible scenario).

Also, does this make #147 obsolete?

@kelltom kelltom changed the title add "get_first_indice()" method to morg api and distance calculation to geometry.py Add Morg API method to get first item occurrences and distance calculation to geometry.py Apr 22, 2023
@kelltom
Copy link
Owner

kelltom commented Apr 22, 2023

It's possible that I'll split the API and the Geometry work into two separate PRs to keep it clean. Might be easier to accept the other one you made, then remove the API changes here so it's just Geometry stuff. Depends if this API code is different from the previous PR or not.

@WillowsDad
Copy link
Contributor Author

WillowsDad commented Apr 22, 2023

Hey, I'm curious about what the use cases are for sorting RL objects from left to right.

Wondering if maybe we can make distance calculations way more robust (e.g., allow for sorting by passing a point instead of making functions for each possible scenario).

Also, does this make #147 obsolete?

The code is different and more robust then #147, updated #147 with that code. So that part of this PR can be deleted, yes. This was supposed to be only the geometry changes. Woops

@WillowsDad
Copy link
Contributor Author

Hey, I'm curious about what the use cases are for sorting RL objects from left to right.

Wondering if maybe we can make distance calculations way more robust (e.g., allow for sorting by passing a point instead of making functions for each possible scenario).

Also, does this make #147 obsolete?

USE CASE:
Only really useful for tile-based pathing (when walking to bank choose the farthest from the edge, and when walking back choose the closest from edge). The reason the sorting from center wouldn't work is because you could be in the middle of two objects the same distance. Your request for a change to calculate distance by passing the points would serve the same purpose and be more robust, I could just pass the parent container left-edge and get the same result. I can work on that now.

@kelltom
Copy link
Owner

kelltom commented Apr 27, 2023

Good point, I'll take a look this week/weekend some time. No pressure, I will be able to implement it if you don't have time. Not sure why I didn't think of tile-based movement.

@WillowsDad WillowsDad closed this Apr 29, 2023
@WillowsDad
Copy link
Contributor Author

closed because I pushed the same changes to geometry pr making this obsolete. #160

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants