Repeat amount of max health

Started by OliB2012 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Apr 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Repeat amount of max health

Hello. I'm trying to make a custom prodocure that will cause a piece of code to repeat the amount of times that the current hp is at. Anyone know how?

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Doesn't this work?
Thu, 11/07/2024 - 13:14

Doesn't this work?

Joined Apr 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I tried that
Thu, 11/07/2024 - 21:21

I tried that

Joined Apr 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
its soposed to do damage…
Thu, 11/07/2024 - 21:25

its soposed to do damage every 60 ticks and when I do that it waits 60t the does 19 damage

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This is due to how the wait…
Thu, 11/07/2024 - 22:31

This is due to how the wait block works. Putting a wait block in a repeat 20 times(or repeat health times if health=20) block triggers the wait 20 times at once, each trigger waits 60 ticks, but as they all start at the same time, they all finish at the same time.

Explanation aside, there is a solution.

First you need to create a local number variable called 'delay'

Second, you need to switch the '60' in wait 60 ticks to be 'delay' for wait 'get number variable delay' ticks

Third, you need to put a 'set number variable' block before the wait block but still in the repeat block.

Fourth, configure the 'set number variable' block to set 'delay' to 'delay' + 60, by using the math block for addition and then setting 'delay' in one side and the '0' block configured to be '60' instead in the other.

That should accomplish the desired effect.