Oh boy, enjoy trying to read through this headache of a post!
So, I have been trying to make a crafting system for about 3 hours now, and I am finally resorting to the developer forums…
Basically, how it works is that the players inventory is stored in a table:
You can add items:
And also remove items:
(excuse any errors in this code snippet, i just changed it a bit for testing and im not 100% sure if it works yet, changes will be reverted)
And this all works fine! But trouble really began when I tried making crafting…
I tried looping through each item in the recipe, and then put the name of each item in the players inventory in a list, and then checked to see if the name was the same, and then checked the amount the player had in their inventory and compared that with the amount needed.
This did not work, because whenever i broke the loop it just didnt work for some reason? Probably bad code but I can’t be bothered to spend another 15 hours looking for the problem.
So, could anybody tell me the REAL way to do this? I have looked through many dev forum posts with nothing that I could use for my specific crafting system. Also, don’t just say “Compare the tables” or whatever. Please explain what you mean when you say something like that.
Thank you!