Not long ago, I posted some code on drawing an inventory. Now in extension form!
It requires Joey’s sprite utils extension.
Here’s an example:
Controls: (for example above)
- Inventory closed:
- A to “eat.”
- B to cycle through slots.
- Inventory open:
- Use arrow keys to select items.
- Use A to transfer items.
- Use B to switch the cursor between the toolbar and inventory.
Yes, the example is quite big but it’s smaller than doing it without an extension.
Note that it doesn’t help you manage your inventory, it only draws it for you. But you can also access the array that holds the items inside with the
get items block and do standard array manipulations on it, but you will have to
force redraw it after because it doesn’t track the changes you make to it. It also doesn’t limit how many slots you can have in a toolbar or in an inventory, but screen-space-wise, it’s limited to 7 and 32 respectively. The toolbar and inventory is also just a sub-classed sprite, so you should be able to use the sprite-data extension to pair it to a specific sprite, although I did not test this. (Please let me know if it works!)
Note: The description part of items is not used by the extension. You can use it for whatever you want, it just must be a string.
Enjoy! Would definitely appreciate suggestions on improving this extension.