Good afternoon,
I have a countdown in typescript format, I would like to know how can I make the countdown start and end with an interaction with a coblocks carácter?
let textItem = Scene.getItem("YPu7Q7uO") as TextItem
let cubeItem = Scene.getItem("h7hnd1Yv") as Cuboid
// Declaramos una variable que vamos a utilizar para almacenar el tiempo restante
let timeRemaining: number;
// Declaramos una variable que vamos a utilizar para almacenar la cuenta atras presente
let currentCountdown: Disposable = null
// Creamos una función que se encargará de actualizar la cuenta atrás
function updateCountdown(): number {
// Decrementamos el tiempo restante en un segundo
timeRemaining--;
// Si el tiempo restante es mayor o igual a 0, actualizamos el contador en el objeto TextBillboard
if (timeRemaining >= 0) {
textItem.text = timeRemaining.toString()
}
// Si el tiempo ha llegado a 0, detenemos la cuenta atrás y mostramos un mensaje
else {
currentCountdown.dispose()
textItem.text = "Cuenta atrás finalizada!"
return 1
}
}
if (cubeItem.active) {
if (currentCountdown != null) {
currentCountdown.dispose();
}
timeRemaining = 60.0
//actualizamos el contador en el objeto TextBillboard
textItem.text = timeRemaining.toString()
// Ejecutamos la función cada segundo para actualizar la cuenta atrás
currentCountdown = Time.scheduleRepeating(updateCountdown, 1.0)
}
I would like the countdown to start when the question is answered with a yes. And finish either when you have the answer and answer with another questionnaire, or when it reaches 0, if it reaches zero I want you to say that you have lost and return to the starting scenario.