How do you make a cooldown and how do you make something dissapear
help me i need this
Well, for cooldowns, you just use a variable and you lower its value until it reaches 0, and then you would have to check if, when it reaches 0, you can perform some action to reset the cooldown
// The variable that will be used for time
cooldown = 0
update = function()
// If "cooldown" is greater than 0, it will decrease
if cooldown > 0 then
cooldown -= 1
// And if it's equal to 0 or less, then you can place the action you want to perform
else
// Here's the action
if mouse.press then
print("Action! (Cooldown enabled)")
// And you must set the "cooldown" to a value greater than 0 (reset)
cooldown = 40
end
end
end
And for something to disappear, it's similar to a cooldown, only it's not for measuring time, but rather for the variable we'll use at the beginning to store the opacity value of whatever we want to make disappear
// This stores the opacity value
alpha = 60
update = function()
// If the opacity is greater than 0, it will decrease
if alpha > 0 then
alpha -= 1
end
// This is just to restart the animation with one click
if mouse.press then
alpha = 60
end
end
draw = function()
screen.clear()
/*
Here you use the opacity value; you have to divide
it by the maximum value it will have (in this case 60)
This is because the system only accepts values between 0 and 1
*/
screen.setAlpha(alpha/60)
screen.drawSprite("icon",0,0,20,20)
/*
And this is just to set the opacity to maximum for
the other things you want to draw
*/
screen.setAlpha(1)
end
Schedule----------------------------------------------------------------------------------------------------------------------------------------------------------- 1."after"
after 5 seconds do
backToMainMenu()
end
2."every"
every 200 milliseconds do
score += 100
end
3."do"
do // the code enclosed will be executed in a new separate thread
for i=1 to 100000000
doHeavyWork(i)
end
end
4."sleep"
sleep 1 second
sleep 200 milliseconds
sleep 200 // if unspecified, it is milliseconds by default