So as you can see, from breaking the inventory structure array, i made an array from the item and filtered to search for “Can Pickup”, then with the length i get a substring and print it. When you refresh the inventory ingame, it prints some number 1 depending on the “amount” of “Can Pickup”. The problem is that getting this i am not able to use it as a condition for a branch, which is my objective:
What you are making is really strange.
While looping throw your inventory you are building an array from every item in inventory.
You always have a “list of items” with only one item. Why?
Why do you check your inventory for “can pickup”. Inventory items are already pickeduped so no need to check them.
If you really want to get the number count of this “can pickup” items you should plugin inventory array into your filter array function and call it only once before foreach loop or after loop completed.
The thing is that i have already thought about doing the filter array function with the inventory array, but apparently i can’t do that because the variable Inventory is a InventoryStructure variable, from a structure blueprint. I thought that this way the job could probably be done with ease, but because this was not possible i started searching for alternatives.
Or maybe i’m wrong and there is a way to filter the Inventory array.
Than add local variable “canpickupCount”. After break inventorystruct → get item class → check if it is “can pickup” → increase canpickupCount + 1 → after loop completed print canpickupCount
Ok, so i tried doing what you proposed but instead of getting the exact amount of “Can Pickup” it appears to be adding 1 for every can in the inventory.So if i have 1 “can pickup” i get “1”, but if i have 2 “can pickup”, i get “3” I might be doing something wrong, but i don’t know what.
you get 1 if you have one and 3 if you have 2? or do you get 2 if you have 1?
where is this code called? I guess now you dont reset you canpickupCount variable to 0.
You have 2 ways:
you should create a function “refreshInventory” copy everything there and create local variable canpickupCount only for this function. call this function when event “refreshInventory” is triggered.
If i picked up 1, i get 1. If i picked up 2, i get 3 because it added 1 for every can i currently have to the float, getting 3. I picked up 3, i get 6. And so on. This was all plugged in the foreachloop located in the RefreshInventory custom event.
However i did what you said, called the new function right after the RefreshInventory custom event was fired, and it worked like a charm.
No i do not only have “can pickup”. I can also pick up a “log pickup”. I wanted to make this in order to use the canpickupCount to fire a custom event, like if you have more than 4 print “You have more than 4 cans”
Hold on, sorry to keep asking for help, but i’ve done some further testing and i noticed two things:
I was using a regular variable withing the new function, and as i changed to local variable, i was unable to add 1 to the variable value
Although i put the InventoryStructure variable into the function, got it, broke it, got the class of the item, compared if is child of “can pickup”, and used this as a condition, if i pickup the “log pickup” it still adds 1 to the variable.
try to delete and to readd this variable. dont forget to set this to integer.
that because you are using “is child of” function. you should use “equals” function. I guess parent class of “log pickup” is “can pickup” so basically “log pickup” is “can pickup” too.
For some reason nothing seems to have been fixed. The local variable still won’t add (I’ve read something about an Assign node but i can’t create it).
I also changed the “is child of function” node to “equal” node, but apparently the item i am getting is not equal to “can pickup”? Because if i fire the print string when the condition is false it prints, but if its true it doesn’t. I’ll take a closer look at what i am picking up and i’ll report again.
Let’s say you start playing and you pick up the “can pickup” before the “log pickup”. All the following items you pick will be recognized as “can pickups”, even if you pick up the “log pickup”. And vice-versa, if you pick up first the “log”, the others will be recognized as “log pickups”.
About the local variable, i don’t know how to deal with it but using a regular variable.
So apparently the issue has to do something with the inventory system itself. I’ll try to make another system and use the method you told me and test if that works.