No problem, just a suggestion.
I feel like, to add a bit more possibility for anims/game design, there should be a delay command!
It might look like this stayOnFrameFor(5); 5 being the number of seconds hung on a frame, this could solve long projects hanging on one frame for a while by just staying on one frame for 5 seconds!
I haven’t looked into more solutions.
NOTE: I KNOW IT’S POSSIBLE, THIS COULD BE A WAY TO SAVE TIME DOING IT cause i’m a total noob at this and a simpler way to do it would be beneficial to others and me.
yet another poorly made concept is below
there’s a way you can do this:
function sleep(milliseconds) {
const date = Date.now();
let currentDate = null;
do {
currentDate = Date.now();
} while (currentDate - date < milliseconds);
}
then put:
sleep(number of seconds you want to put here then add 3 zeros ex: 5000 (5 secs));
But that hangs the entire tab, not just the script.
my guess is that pkhead is replying to tazer. pkhead is saying that the solution only works on 1 tab, not the whole clip.
wait then go1-20-2021_18-57-15.wick (2.6 KB)
I’ve used this method some times… (I know it isn’t a problem, just wanted to share my own way of doing it.)
Here are the scripts (explained, kinda.):
Default:
project.secondsleft = 5; //the name says it, the seconds left until it goes to the next frame.
project.second = 13; //if update runs every tick, then 13 ticks would be really close to a second. (there are 20 ticks but i feel 13 is better)
Update:
project.second -= 1; //it subtracts every tick 1 from project.second.
if (project.secondsleft !== 1) { //if project.seconds left doesn’t equal 1.
you.setText(“You’ll go to the next frame in " + project.secondsleft + " seconds…”);
}
if (project.secondsleft === 1) { //if project.second does equal 1.
you.setText(“You’ll go to the next frame in " + project.secondsleft + " second…”);
}
if (project.second === 0) { //if the 13 ticks have already passed.
project.secondsleft -= 1;
project.second = 13;
}
if (project.secondsleft === 0) { //if there are no seconds left.
gotoNextFrame();
}
That sounds even more complicated than tazer’s😳
I think what you’re looking for is the settimeout function
setTimeout(function(){
alert("Testing");
}, 3000); // 3000 milliseconds until the window alerts "Testing"
I think this currently only with works window related code like alert, open, close, confirm, print, reload, etc.
It would be a cool feature to have if it worked right.
Thank you for the suggestion
Here’s how I would have something happen for a set amount of time…
Default
project.Sec=new Date().getSeconds();
project.Seconds=0;
Update
if(project.Sec!==new Date().getSeconds()){
project.Sec=new Date().getSeconds();
project.Seconds++;
}
if(project.Seconds>3){
// Do something after 3 seconds
}
if(project.Seconds<3){
// Do something before 3 seconds
}
if(project.Seconds===3){
// Do something at 3 seconds
}
Also, just noticed that if it waits 5 seconds, then it should go to the next frame instanty after 4 changes to 5,instead of it staying in 5 and changing instantly after 6. (unless i’m wrong…i’m probably wrong.)
Sense the seconds started at zero, and every second a second gets added, then the seconds is set to 5 seconds exactly when 5 seconds come by, therefore when seconds is set to 5, the project is supposed to go to the next frame. If project.Seconds was set to 1 in default script, then you would’ve needed to wait until project.Seconds is equal to 6 before 5 seconds go by.
Time can get is confusing
Oooh, right, well, everybody adjusts it as they want right?
this command works! However there’s also a button that you can press to bring you to the next frame manually, and line one on update is interrupting that so the only way to get out is by waiting. @Steven
Edit: this was just a bug with .0, the .3 revision doesn’t have this issue.