This project demonstrates an expandable crafting system using only one sprite. Press the green flag and start crafting! To try it out, try crafting an iron_pickaxe. Then, try it out again with "Show Process?" on! If Show Process? is on, you can see how the system works. Pay attention to how the "item quantities required" slowly reduce to 0 and get deleted. To add more items, press 1-3. =================== To use this crafting system in your own project, simply copy the Craft sprite inside this project. To add your own crafting recipe, follow the instructions given in the comments inside the project. Sample recipes are given too.
How does the system work? 1. The "items required" list stores the names of the items required to craft. The "item quantities required" list stores how many of each item is needed. 2. After the material requirements have been set, the system will begin crafting. 3. The system looks through each item in the INVENTORY list. 4. For each item, check if that item is required in the "items required" list. 5. If true, subtract the respective "item quantities required" by 1. Then, if it becomes 0 or less, delete that item from "items required" and "item quantities required". Also, store the index of that item in INVENTORY in a separate list called "indexes to be deleted". 6. After looking through all items in the INVENTORY list, check if there are still any "items required". If true, that means some items are still missing, so crafting fails. If false (i.e. length of "items required" = 0), then crafting is successful. 7. If successful, delete all "indexes to be deleted" from the INVENTORY. Then, add the crafted item to the INVENTORY. You can streamline this crafting system even more by storing all recipes in a list. Unfortunately, this project does not cover that far.