Delaying executuin
I was wondering if there was a microScript version of setTimeout(() => {} b/c I need it for a weapon cool down and cant get it to work when nested in a js file
I was wondering if there was a microScript version of setTimeout(() => {} b/c I need it for a weapon cool down and cant get it to work when nested in a js file
Show code .
I am almost certain that setTimeout works in conjunction with MicroScript because I have experimented with this command.
In MicroScript itself there is the possibility of using "threads" - one of the thread varieties can start after a certain time.
This can make writing code easier - and debugging it more difficult.
after 5 seconds do
backToMainMenu()
end
every 200 milliseconds do
score += 100
end
Weapon = class
consstructor = function()
this.isCoolDown = false
end
fire = function()
if not this.isCoolDown then
this.isCoolDown = true
print( "Fire!")
after 5 second do
this.disableCoolDown()
end
end
end
disableCoolDown = function()
print("Cooling disabled!")
this.isCoolDown = false
end
update = function()
if keyboard.SPACE then
this.fire()
end
end
end
init = function()
weapon = new Weapon()
end
update = function()
weapon.update()
end