Variable does not increment

Started by Ypermat on

Topic category: Help with Minecraft modding (Java Edition)

Active 1 year ago
Joined Aug 2018
Points:
820

User statistics:

  • Modifications: 2
  • Forum topics: 18
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 74
Variable does not increment

Hello !

I am trying to do an achievement + looting tables mod to work with a modpack.

I am trying to check how many zombies / zombified creatures (including piglins) the player have killed.

But the problem is that the variable is not going up. I displayed multiple messages ("before add" and "after add") to see what is going on and see the second image, it seems that the variable reset to 0 every time.

The variable is created as "number".

1st image :

Second image :

Thank you in advance !

Active 1 year ago
Joined Aug 2018
Points:
820

User statistics:

  • Modifications: 2
  • Forum topics: 18
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 74
1st image : Second image :
Sun, 05/29/2022 - 20:01

1st image :
1st image

Second image :
2nd image

Active 2 years ago
Joined Mar 2022
Points:
453

User statistics:

  • Modifications: 0
  • Forum topics: 4
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 65
You're using a Local…
Sun, 05/29/2022 - 20:19

You're using a Local Variable to store your count.  These are "local" to the procedure trigger instance that they are in, they reinitialize each time the trigger is called.

You need to use a Global Variable, in this particular case, the PLAYER_PERSISTENT variety.  You can assign global variables by opening the "Variables" tab on the main workspace.

Active 1 year ago
Joined Aug 2018
Points:
820

User statistics:

  • Modifications: 2
  • Forum topics: 18
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 74
Thanks for the answer !…
Sun, 05/29/2022 - 20:37

Thanks for the answer !

Unfortunatly, now, the variable won't even go up...

Sorry to bother you :/

code

result

Active 1 year ago
Joined Aug 2018
Points:
820

User statistics:

  • Modifications: 2
  • Forum topics: 18
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 74
I figured it out, I'm just…
Sun, 05/29/2022 - 20:48

I figured it out, I'm just dumb, the variable was for the target entity instead of the source entity, the player...

Thank you very much !