kongkim
(kongkim)
March 17, 2016, 7:44am
11
Here is my function code that is used to consume item stacks
I pass in the master Item’s current ItemRating value (master Item is what is getting the upgrade), Item that is to be consumed, the targets current item quantity (I could have just grabbed that in the function since I have the item there but meh), and a value I pass that is needed to be consumed (1,2 or 4) if that stack doesn’t meet that requirement it just breaks out and looks for another stack. If it is >= then it takes that consume amount * -1 so it’s now a -(neg) value it will consume from that stack (if the stack was 2, and I increment by -2 it will destroy the stack also don’t forget to check “Is from consumption”)
Now this is not perfect because if I needed to consume 3 of something, and I had 3 stacks of 1. My code won’t consume anything. If I wanted to do that I’d need to create arrays, and loop through and collect all the item stacks, and slowly consume from them until my amount needed is met. And that’s if the total found stacks do add up to 3 or greater. So this logic can be made better. But I have other things to learn before I sink time into perfecting this (as it will take time to set it all up correctly, and not have it cause lag with too many loops)
Thx Is not home right now but will take a look at it when im home again.
But i might have one stupid question :S
How do this know what item type/stack to consume the item from?
The thing is i have a special type og torch. and i need it to remove one item from a fuel stack that is not being burned everytime you light the fire.