Okay, it's official now. I've gone over to the dark side of the force and decided to "play" with Javascript inside Tumult!
I'm getting a billion ideas because now I don't feel totally limited in creating with code. I am always waiting for a more "programming friendly" version of Hype because I am not and will never be a programmer, however, in the meantime, I am trying to do something.
I am sure @jonathan will be pleased with this....
A few days ago I got the unhealthy idea to make, for a personal promotional project of mine, an interactive game book. I have decided that some of the reader's choices will be made by "rolling dice." Madness!
Remember that I am not a programmer however, I have succeeded in 90% of my intent. I can generate a causal number and make the related die appear.
Now I would like after a certain number of seconds to go to a certain scene (from 1 to 6). so what I thought to do, to use the variable where the number is at random so that depending on the number chosen, Hype takes you to that scene...
But it seems that a function variable cannot be used elsewhere.
Any ideas?
Yes but human advice...remember I am not a programmer. If you start with technicalities I will get discouraged and stop...
var intervallo = setInterval(function() {
var numero_casuale = Math.floor(Math.random() * 6);
if (numero_casuale === 1) {
hypeDocument.setElementProperty(dado1, 'opacity', 1);
hypeDocument.setElementProperty(dado2, 'opacity', 0);
hypeDocument.setElementProperty(dado3, 'opacity', 0);
hypeDocument.setElementProperty(dado4, 'opacity', 0);
hypeDocument.setElementProperty(dado5, 'opacity', 0);
hypeDocument.setElementProperty(dado6, 'opacity', 0);
}
if (numero_casuale === 2) {
hypeDocument.setElementProperty(dado1, 'opacity', 0);
hypeDocument.setElementProperty(dado2, 'opacity', 1);
hypeDocument.setElementProperty(dado3, 'opacity', 0);
hypeDocument.setElementProperty(dado4, 'opacity', 0);
hypeDocument.setElementProperty(dado5, 'opacity', 0);
hypeDocument.setElementProperty(dado6, 'opacity', 0);
}
if (numero_casuale === 3) {
hypeDocument.setElementProperty(dado1, 'opacity', 0);
hypeDocument.setElementProperty(dado2, 'opacity', 0);
hypeDocument.setElementProperty(dado3, 'opacity', 1);
hypeDocument.setElementProperty(dado4, 'opacity', 0);
hypeDocument.setElementProperty(dado5, 'opacity', 0);
hypeDocument.setElementProperty(dado6, 'opacity', 0);
}
if (numero_casuale === 4) {
hypeDocument.setElementProperty(dado1, 'opacity', 0);
hypeDocument.setElementProperty(dado2, 'opacity', 0);
hypeDocument.setElementProperty(dado3, 'opacity', 0);
hypeDocument.setElementProperty(dado4, 'opacity', 1);
hypeDocument.setElementProperty(dado5, 'opacity', 0);
hypeDocument.setElementProperty(dado6, 'opacity', 0);
}
if (numero_casuale === 5) {
hypeDocument.setElementProperty(dado1, 'opacity', 0);
hypeDocument.setElementProperty(dado2, 'opacity', 0);
hypeDocument.setElementProperty(dado3, 'opacity', 0);
hypeDocument.setElementProperty(dado4, 'opacity', 0);
hypeDocument.setElementProperty(dado5, 'opacity', 1);
hypeDocument.setElementProperty(dado6, 'opacity', 0);
}
if (numero_casuale === 6) {
hypeDocument.setElementProperty(dado1, 'opacity', 0);
hypeDocument.setElementProperty(dado2, 'opacity', 0);
hypeDocument.setElementProperty(dado3, 'opacity', 0);
hypeDocument.setElementProperty(dado4, 'opacity', 0);
hypeDocument.setElementProperty(dado5, 'opacity', 0);
hypeDocument.setElementProperty(dado6, 'opacity', 1);
}}, 150);
// fermo il conteggio dei dadi dopo 4 secondi
setTimeout(function() {
clearInterval(intervallo);
}, 4000);//passo alla scena sucessiva dopo 8 secondi
setTimeout(function() {
//clearInterval(intervallo);
hypeDocument.showSceneNamed(numero_casuale);}, 8000);