Page 1 of 1

[EOS] Timer sync and async

Posted: Tue Jul 19, 2022 8:28 pm
by Lady N
Hello,

i was trying to use two differents actions in a page.
One is the general flow using a hidden synchronous timer to let the player look at the image before next refresh.
And the second is the asynchronous flow with a visible asynchronous timer that lead to a action.

But it seems we can't have two timer alive at the same time...
I launch the asynchronous one, and when the synchronous timer is launched the asynchronous one is killed and the action event occur...

Is there a way to manage what i want ?

My goal is to refresh a random image each 2s (i goto the same page when the timer end) while a timer is running and which goto another page when done.
Maybe there is a way to change the image of the page via eval ?
I did not find anything usefull in the globals var, and in EOS API.

Regards,
Lady N.

Re: [EOS] Timer sync and async

Posted: Tue Jul 19, 2022 9:10 pm
by indyc
When I do an asynch timer followed by a normal timer, both are shown at the same time for me and work fine.

However, any page changes (the go-to action) kills asynch timers without executing their action. The fact that the action is actually occurring for you makes me think something else is going on.

If you want to share your tease preview link with me here or by PM I would be happy to fix it for you.

Re: [EOS] Timer sync and async

Posted: Tue Jul 19, 2022 9:40 pm
by Lady N
Oh... Thanks for the answer.
Then my image refresh method is not the good one.

Is there a way to refresh x Time an image without a goto ?
My tease is currently totally fucked up.
I will share a snippet in a new tease tomorrow if no one have an answer.

Re: [EOS] Timer sync and async

Posted: Tue Jul 19, 2022 10:24 pm
by indyc
Depending on how many times you plan to do it/loop it my approach would be to put multiple random picture callouts in the same page separated by timers. Someone who doesn't know coding like me has a few pages that are over 300 lines and it works well enough. If no one else helps by tomorrow, looking at what you are trying to do would help me offer a better suggestion.

Re: [EOS] Timer sync and async

Posted: Wed Jul 20, 2022 5:43 am
by Lady N
Got a pretty good answer in DM from fapnip that solve my use case issue.
For visible async timers that survive GOTOs that CAN execute actions, see the timer option in the Notification create action (You need to enable Notifications module in Options.) However, when the async action fires any waiting action, like a paused say, a choice, a synchronous timer, etc., will be skipped, the actions in the async executed, then the action following the previously waiting action executed -- unless a GOTO happened.
It doesn't show the timer number unfortunatly. More stress for the player. :lol:

Re: [EOS] Timer sync and async

Posted: Wed Jul 20, 2022 1:59 pm
by Thamrill
I don't know if I understood correctly, but if the aim is having a loop updating every x seconds with a background timer going on for longer, I put this together: https://milovana.com/webteases/showteas ... 16574f1f46

This shows a random image every minute, with a longer timer of 10 minutes going on in the background. The only issue is that the total timer starts with a new value on every page (i.e., on the first page starts on 10, on the second 9, etc). However, if the code was blocking anyhow, on the newer page it would consider the real residual time.
So even if you skip the timer or if there is a say action taking longer to be executed, the async would always take 10 minutes.
This would be especially true if you were to use a random timer.

Is this somehow what you wanted to achieve?

Re: [EOS] Timer sync and async

Posted: Wed Jul 20, 2022 2:54 pm
by Lady N
It is a nice alternative at what send me fapnip.

But, is your second timer should be a multiple of the first one ?
Or are they totally independant ?

Re: [EOS] Timer sync and async

Posted: Wed Jul 20, 2022 3:43 pm
by Thamrill
Lady N wrote: Wed Jul 20, 2022 2:54 pm It is a nice alternative at what send me fapnip.

But, is your second timer should be a multiple of the first one ?
Or are they totally independant ?
Totally independent, basically when you set up the loop you define a number variable in an eval function equal to the current time+the duration (in milliseconds).
At every reload you set the duration of the async timer to the difference between end time and current time and you are done

Edit: in principle, you could avoid the async timer at all, now that I think about it. After the timer put an if action with the condition end time>current time. If it is, return to the loop page, otherwise exit the loop

Re: [EOS] Timer sync and async

Posted: Wed Jul 20, 2022 9:42 pm
by Lady N
Thamrill wrote: Wed Jul 20, 2022 3:43 pm Edit: in principle, you could avoid the async timer at all, now that I think about it. After the timer put an if action with the condition end time>current time. If it is, return to the loop page, otherwise exit the loop
Wrong, because i wanna show the time. :lol:

I tested it, and it work very well.
Just need to adjust to 500ms the end test to gain reactivity due to the pic timer (1.1s) :
if( current time + 500ms >= end time )

Re: [EOS] Timer sync and async

Posted: Thu Jul 21, 2022 4:58 am
by Thamrill
Lady N wrote: Wed Jul 20, 2022 9:42 pm
Thamrill wrote: Wed Jul 20, 2022 3:43 pm Edit: in principle, you could avoid the async timer at all, now that I think about it. After the timer put an if action with the condition end time>current time. If it is, return to the loop page, otherwise exit the loop
Wrong, because i wanna show the time. :lol:

I tested it, and it work very well.
Just need to adjust to 500ms the end test to gain reactivity due to the pic timer (1.1s) :
if( current time + 500ms >= end time )
Ah right, yes