Repository navigation
How can I programmatically check what item is in the first, second, third, etc. inventory slot? #306
Answered
by
ivankrivenko
ivankrivenko
asked this question in
Q&A
|
Hi! Thanks in advance! |
Answered by
ivankrivenko
Oct 21, 2025
Replies: 1 comment 2 replies
|
Hi! I assume we are talking about basic inventories and the first item would be the "oldest" one, i.e. the one that was first added? var all_items = inventory.get_items()
var first_item = all_items[0]
var second_item = all_items[1]
# etc.
var last_item = all_items[inventory.get_item_count() - 1] |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi!
I’ve found the solution.
To get the item in the first or second slot, I needed to use the get_item_at method in GridConstraint.
https://github.com/peter-kish/gloot/blob/master/docs/grid_constraint.md
Here’s the code:
Thank you so much for your help!
I can’t believe I missed that in the documentation earlier. 😊