Getting a colective int value from items in your inventory?

Started by woodcraft on

Topic category: Help with MCreator software

Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Getting a colective int value from items in your inventory?
Tue, 08/24/2021 - 15:48 (edited)

How would one go about getting a single int value of all things in a inventory or gui? Let's say I want to count how many "powerstones" are in my inventory, as of right now I'm using "in inventory tick" to set my values but that only supports 1 item and 1 number from that item "when in inventory tick add 40 to int power" etc but this won't work if I where to try addition that would only result in a timer that constantly adding 40 to that int value per tick.

Any idea on how to remake this system to allow me to use addition when having more than one "powersone"? to clarify 1 powersone = 40, and another one could have the value 30 would then be 70 right? so how would I implement a system that scans for these powerstones and then combinds their different powerlevels to one int value? 

I also made a system that Check each slot individually for a certain powerstones but that's not optimal since that would make adding new items harder and I also tried using local variables for each slot so that first you set the local variable based on what items is in that slot and then at the ad settinf the global variable to all the local added up into one but the issue with this is still that it takes a lot of effort to just add a new powerstone and there has to be a better way.

Edited by woodcraft on Tue, 08/24/2021 - 15:48
Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
bump 2 electric boogaloo
Wed, 08/25/2021 - 06:21

bump 2 electric boogaloo

Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
bump 34, bump in space
Sun, 08/29/2021 - 13:39

bump 34, bump in space

Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
So, just something to say…
Wed, 05/01/2024 - 03:29

So, just something to say regarding the last paragraph, Local Variables aren't saved, and only really can be used within a specific procedure, so using them to try to add up into a global variable wouldn't work.