Incrementing numerical variable is impossible.

Started by SHB_YT on Sun, 04/26/2020 - 21:36

Topic category: Help with modding (Java Edition)

Last seen on 16:54, 29. May 2020
Joined May 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Incrementing numerical variable is impossible.
Sun, 04/26/2020 - 21:36

Why is this impossible to do.

 

Like I know MCreator is for basic programming but jesus. Can't even increment a number every tick. Wow.

 

I'm not wrong in saying that to do this you would set a variable to itself plus 1? So that each time it's called it sets itself to a value of itself plus 1?

Like how you would increment a variable in any programming language ever.

 

Come on MCreator, sort yourself out.

Last seen on 16:33, 2. Jun 2021
Joined Nov 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Local variables only exist…
Sun, 04/26/2020 - 22:03

Local variables only exist within the procedure, and for as long as the procedure is being executed. If you had some code like this

for (int i = 0; i < 5; i++) {
   int x = 3;
   x++;
}

you wouldn't expect the variable to reach 8.

Have you considered storing the variable somewhere out of the procedure (ex. scoreboard, block nbt)? I'm positive this has already been covered by other topics.