How can I programmatically check what item is in the first, second, third, etc. inventory slot? #306
-
|
Hi! Thanks in advance! |
Beta Was this translation helpful? Give feedback.
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] |
Beta Was this translation helpful? Give feedback.
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. 😊