Variable does not increment

Started by Ypermat on

Topic category: Help with modding (Java Edition)

Last seen on 10:28, 30. Oct 2023
Joined Aug 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
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 !

Last seen on 10:28, 30. Oct 2023
Joined Aug 2018
Points:

User statistics:

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

1st image :
1st image

Second image :
2nd image

Last seen on 05:05, 30. Oct 2022
Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
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.

Last seen on 10:28, 30. Oct 2023
Joined Aug 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
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

Last seen on 10:28, 30. Oct 2023
Joined Aug 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
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 !