Topic category: Help with Minecraft modding (Java Edition)
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.
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.
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)
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.
I will try that, I'm actively messing about with it right now, thank you for the idea though!
Some clarification on my response. The new procedure will still count up indefinitely as the count up part is not in the if block.
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
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.
If you have discord i can hop on there with you to try and help you out
https://discord.gg/6yen8Huf
I do in-fact, joined the server aswell
Sorry about the inconvenience