I am trying to make it so you can use an inventory to get items and then use those items using the toolbar with A and B. I have everything working with the inventory, and selecting an item with A and B to set the toolbar, but when I try to make a function to use the sprite that is in the array, it is breaking the system. I was trying it the way they did on the Makecode Advanced Horticulture game, but it wasn’t working so I downloaded the inventory extension to try, but it still seems to be broken. (See note for how to break code.)
Any help would be appreciated and I’m guessing its something simple I am missing. Thank you.
Inventory Test
Ok, I have figured out the using Item issue, but now have a new issue. I am trying to search my inventory array for the name of the item that I might want to add, to see if it already exists. If it does, I want it to stack, and if it doesn’t then add a new item to inventory. I can’t figure out how to add an if statement to check the inventory for the string of item “name”. Every time I do, it seems not to like the fact that I am looking for a string on a sprite list I guess. I have tried loops, every block in the inventory along with the join block to try and turn it into a string, but have had no luck. In the picture below you can see how I am adding an item, and I think it should be a simple check for the name of new item and if it’s there add to amount… I have spent some time trying to work this out, and it is a crucial feature to move forward in a larger project I’ve been working on, so any help would be very appreciated.
Thanks!