Ive got this on click craft event
Im finding Howmany items i have in the inventory and how many i need for the recipie then spawning the item, This bit works properly, if i dont have enough items it wont spawn the item, I just dont understand how this is working.
Ok so first he clears the count for an array that to me looks like it does absolutely **** all, it holds the information of how many of such item i have in my inventory but is never used again.
Then we goto the Howmanyitemsforcomparison macro, which contains :
Now i understand this, were checking my resource classes and seeing how many of the items i have in my inventory?
If i open the get items stacked function here :
We have 2 local variables which i dont understand what there for as there never used anywhere else. Although this bit definantly works. Id like someone clever enough to explain this to me if possible.
We then move onto the Canitbecrafted macro here:
Which definantly finds how much i have in my inventory and moves on to spawn the right item with the right amount of parts next.
Then i get to the part where i have to delete the right amount of items from my inventory after the item has been spawned. Here:
Inside the function for deleting the items i have :
The strange thing is, If i do this with just one of the items, say the scrap metal. It works, it takes away 1 scrap metal at a time, if the recipie uses 1 scrap metal to make it, then if i make another one straight after because i have 2 in my inventory, it uses the last piece and deletes it from my inv.
The problem arises when i do it to all 3 at the same time, it takes a random number of things from the inventory, I have to make a medkit, 1 of each resource needed to craft. So 1 scrap metal 1 electronic parts 1 adhesive. It will take a random number ill end up with something like 1 scrap metal and nothing else in my inventory after, like it totally makes up its own mind what to take away.
Can anyone get there head round this as ive gone through it again and again and just cant understand it.