Download

Cant Understand This

Ive got this on click craft event

3e8ed8f3218145937fb08d9307c73cac61e510b5.png

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 :

d19903dc2b72ee276f997b72e49fd46a164179df.png

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 :

1a9b84189d0ed39f57f39c6ecf4c70ff2af72dfb.png

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.

Thanks.

maybe the array only holds numbers, so im telling the inventory to delete 1 something, 3 times. As it takes 1 of each item to craft. That would explain the random item counts when having 2 of each item in my inventory.

That then goes on to ask how would i make it tell the inventory to delete 1 of the 0 index = scrap metal 1 of the 1 index = electronic parts and 1 of the 2 index = adhesive.

And the inventory index would change also with the order the parts are being picked up…right???..Confusing

Yes the items definantly arrange in a different order, when picked up in a different order. So does that mean there index would change in the inventory. Because that then makes it near impossible to target and delete the right index on command, If its only numbers.

As you can see here, in my inventory, when i click the drop button, it uses the inventorybuttonclicked variable and the inventory array to delete an item from the inventory when dropped, this works perfectly:

With crafting i have set values of items within the recipie that need deleting from the inventory on completion. It obviousely reads them to spawn the item. But i cant reverse engineer it on my own properly, and i dont know anyone with any programming experience to ask either.

Given the inventory index will fluctuate with the order of items picked up and the fact that i dont click the items in the inventory to delete them on recipie completion. How do i direct the correct number of parts in the recipie to the correct array index for each resource that needs deleting.

Think my heads gunna explode…

Thanks

looks like no one understands it LoL

Dear viggerz,

The reason reply is to thank you for putting this up since I’m also having trouble understanding my own inventory and crafting system. I’m going to use this information as reference for my own crafting system. If I figure out what the solution is for the problem you are having when you craft an item with your crafting system, be assured that I will let you know as soon as possible.

Kind regards