Skip to content

Changes for inventory_grid.gd regarding create_and_add_item for implementing get_item_at_position #38

Answered by peter-kish
filipinyo asked this question in Q&A
Discussion options

You must be logged in to vote

Yeah, helper functions like create_and_add_item_at and get_item_at are still missing, however I think it shouldn't be hard to implement them.
One thing you're missing in your implementation is that items with missing KEY_GRID_POSITION property are considered to be positioned at (0, 0). This makes the whole thing a lot simpler, as items can be added at certain positions simply by adding them at (0, 0) and moving them to the desired grid coordinates:

func create_and_add_item_at(prototype_id: String, position: Vector2) -> InventoryItem:
    var item = create_and_add_item(prototype_id)
    if item:
        move_item_to(item, position)
    return item

Getting items at specific grid coordinates…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@peter-kish
Comment options

Answer selected by peter-kish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #37 on August 16, 2022 20:18.