[SOLVED]Can't figure out how to make a cooldown work on this procedure.

Started by lemonguy on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jan 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[SOLVED]Can't figure out how to make a cooldown work on this procedure.
Tue, 01/07/2025 - 19:23 (edited)

I've tried a few different ways to try and get around making a cooldown for my procedure, I thought it'd be pretty simple but it turns out when you use the wait X ticks procedure with it, It just completely breaks the whole thing, so I've been swapping methods for a little while and I'm completely stumped at this point.

https://imgur.com/Xp5DeYq (This is a link to what my block code looks like, as of right now)

https://imgur.com/anf3jmF (This is the procedure that handles the cooldown timer)
I'm sure this is probably just me being inexperienced and not understanding something properly, either way I'd be extremely happy if somebody could point out where I went wrong and tell me how to do this properly.

 

The main person who commented, nilek20 managed to figure out over discord after a few hours that the problem was that I was using Local Variables, which in his words "this is because local variables are only "stored" for each time the procedure runs. so the number was resetting each time the procedure ran."

I hope this helps anybody else having the same issue.

Edited by lemonguy on Tue, 01/07/2025 - 19:23
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
First you need to make sure…
Tue, 01/07/2025 - 15:09

First you need to make sure that your Global Variable is false by default.

Second your first procedure looks fine to me but i might be missing something.

Third you need to add to your second procedure. As your second procedure is now it will trigger on every player tick update no matter if the global variable is true or false. This means it will count up forever without stopping. You need to add something to this procedure that only allows it to count up if the Global Variable is True.

Joined Jan 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hello, thank you  for the…
Tue, 01/07/2025 - 16:04

Hello, thank you  for the reply and advice It's actually greatly appreciated, I have been unfortunately unsuccessful in my effort of fixing this code right now but, I did find out that for some reason the global variable was set to true at the beginning which is great, however now the issue is that the procedure works successfully once but then just breaks and is unable to be used again.
https://imgur.com/shej4iR (The updated second procedure, incase you wanted to see it.)
 

Also thank you for the insightful reply, once I can actually get this to work I'll see if I can get it to stop counting when it doesn't need to! (I'll continue testing it in the mean-time)

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The only thing i can think…
Tue, 01/07/2025 - 16:09

The only thing i can think of at the moment is that maby you should move the "Set Number :Local Cooldown" line to before the count and you need to move the count up part into the if block.

Joined Jan 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I will try that, I'm…
Tue, 01/07/2025 - 16:11

I will try that, I'm actively messing about with it right now, thank you for the idea though!

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Some clarification on my…
Tue, 01/07/2025 - 16:11

Some clarification on my response. The new procedure will still count up indefinitely as the count up part is not in the if block.

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Esentally what you want the…
Tue, 01/07/2025 - 16:15

Esentally what you want the procedure to do is.

When the procedure is called

   If the Global Variable is false

      Make sure that the Local Variable is 0

      Increase the Local Variable

      If the Local Variable is at the max point set the Global Variable to False

Joined Jan 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks a lot for the support…
Tue, 01/07/2025 - 16:30

Thanks a lot for the support and fast replies, it mean's a lot to me since this is incredibly frustrating, currently the second procedure looks like this:
https://imgur.com/177TQTu (I hope I've done this right, sorry if I'm doing this wrong)

The issue is still persisting with this change, so I'll keep on trying different things to make this work!

Also thank you for your patience with me.

Joined Jan 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I do in-fact, joined the…
Tue, 01/07/2025 - 16:43

I do in-fact, joined the server aswell
Sorry about the inconvenience