# Inventory Problem

**URL:** https://forum.makecode.com/t/inventory-problem/39473
**Category:** Help
**Created:** [September 24, 2025, 5:19pm UTC](https://forum.makecode.com/t/inventory-problem/39473 "2025-09-24T17:19:27Z")
**Posts on this page:** 1
**Showing post:** 12

<div class="post-metadata">

### Author: ![randomuser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/randomuser/32/32505_2.png) [@randomuser](https://forum.makecode.com/u/randomuser)
#### Post date: [October 15, 2025, 2:11am UTC](https://forum.makecode.com/t/inventory-problem/39473/12 "2025-10-15T02:11:15Z")

</div>

First, to help with lag and help with limiting crafting conditions, we can take this repeated section of code and make it into it’s own function:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/4/2/421aba1a81188e16952bf0e3ef9e413428896da3.png)  
This way, we can simplify the ‘Collect item’ and ‘Lose item’ functions into this:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/f/d/fdcb88bb909a055741fe373bfc52929eacfb78c8.png)  
So we can easily modify the craft function to check for the number of materials:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/b/5/b540f3e2c275b57f62b6af6a75e18a071065d663.png)  
[Here’s the link to add this function!](https://arcade.makecode.com/S75244-41495-71459-91829)

The lag issue is a harder one to fix, but [there are helpful tips in this thread](https://forum.makecode.com/t/how-to-make-arcade-run-faster/20897)!

---

_[View the full topic](https://forum.makecode.com/t/inventory-problem/39473)._
