Started by
xTremQuick
on
Topic category: Help with MCreator software
Hey there,
So Ive got a Keybind to strike lightning at the pressing of the r key. I dont want players to spam this, so I need a cooldown for this. I have no idea on how to add it, so are there any sugestions? tthanks in advance
Edited by xTremQuick on Wed, 07/19/2023 - 20:42
This can be accomplished by using a player lifetime variable that goes down on global trigger player tick update. If you check if the variable is equal to or less than 0 before using the keybinding, and it sets it to whatever cooldown you want in ticks(20 ticks = 1 second) after you press it, it should work.
I cant figure out on how to create the player lifetime variable, asked ChatGPT but I think the answers there are outdated
There is a side tab called variables, when you click on that, the bar at the top of the screen changes to include a button that says 'Add new variable' if you click on that it opens up a menu with three boxes, the top box is where you put the name of the variable, really does not matter, the middle box is a dropdown menu where you can select number variable, and the bottom box is a dropdown menu where you can select player lifetime.
To make the timer go down, create a new procedure, then on the green starting block click the box labeled 'No additional trigger' it will open a dropdown menu that you can select 'On player tick update'(it is a long menu and it may be slightly difficult to find on player tick update, but it does exist in the most recent MCreator version, and has for the last several versions).
After selecting On player tick update, attach the procedure blocks 'Set [timer variable] to:', '[timer variable]'(both under the custom variables tab), you will also need the math block, at first it is set to + but if you click the + you can change it to -, you will also need a static number, 1, the block for it defaults to 0, but you can click it to change it(the second two blocks are under the math tab).
After getting all of the procedure locks, attach them so it is:
"Event trigger - triggered by external call
or when (global trigger): On player tick update
Set [timer variable] to: [timer variable] - 1"
that will work to reduce the timer by 20 every second
Thank you very much, solved it
can someone screenshot the procedure? i made all by instructions but nothing happend
Got you:
thats the variable
heres the procedure
Oh and this is the procedure where I count the variable down
The image is broken, please upload it to the upload pages and send the link
You can right-click on the image symbol and hit open in new tab so you can see the image
where is the "get global" trigger
nevermind lmao
This hasn't worked for me?
I ended up using a logic variable instead.