Forum Discussion

DanielChodos's avatar
DanielChodos
Community Member
16 days ago
Solved

Trigger before a "timeline ends"

I would like to set up a trigger that is based upon the end of the slide timeline minus one or two seconds.  I need this to be variable based, not on a manually set time.   I see three built in "elapsed time" variables, but I don't see a built in variable for the total duration of a slide timeline.  Does anybody have ideas about how to do this? 

  • Hi DanielChodos I'm pleased to announce that I did it! In fact, ChapGPT did all the work. 😄 Let me explain.
    I was very surprised when I looked at your .story file. In all possible cases, SlideElapsedTime is only known at the END of the slide. “Elapsed” is a clue, even for me, who doesn't speak English very well. So, anticipating a temporal event based on an unknown final duration is... difficult.


    I just spent 3 hours this morning making Chappy sweat over the difficulty of finding the expected duration of the slide. He failed a dozen times. Finally, I suggested he look at the progress bar, since its scrolling speed automatically adapts to the final duration as soon as the slide starts. Indeed, in the debugging console, it has a “max” value of 5000 if the slide duration is 5s, 10000 if the duration is 10s, and so on. Chappy warmly congratulated me on this idea and I was very proud of it. The rest was pretty quick. 
    Everything works exactly as you want it to, I think, whatever the length of the slide. Even if you remove the progress bar! Give it a try. The timing (-2s, -5s) of the event is adjustable in the JScode. You can now duplicate this slide and change its duration in the timeline.
    Look at the .story file. It's all there: slides 2 and 3.
    I'd like to know if this works for you.

  • Hello DanielChodos! I'm interested to hear how others in the community have set up their courses to achieve something similar. As far as functionality goes, you could add a trigger that includes conditions. For example, if the timeline reaches a certain point and other criteria are met, like the state of an object changes.

     

    It would be helpful if you could share your project file so we can see what you've created so far! You can share the .story file as an attachment in this discussion.

  • Hello DanielChodos . If I understand your request correctly (that it be flexible and automatic whatever the length of the slide), I don't think you can do it with basic triggers. On the other hand, ask your problem to the JScode enthusiasts on the other forum dedicated to this and I'm pretty sure you'll quickly get an answer (with JScode, that is). I've just asked ChapGPT to do this and he replied “Of course it's possible” and produced a solution in the form of a fairly short code. It looks like it's easy to get the total time of a slide when the timeline starts, and create a “minus 2s” trigger. As I don't have the time to test it to make sure it works the way “you” want it to, I invite you to try it yourself. And please let us know how you get on. 

  • DanielChodos's avatar
    DanielChodos
    Community Member

    ThierryEMMANUEL, you are understanding what I am looking for.  Before posting here, I first tried an online search and the AI response said it could be done with a simple trigger.  It said create a trigger for Timeline Ends and then add a condition using a variable called "Current Time" and then subtract the number of seconds using " -5" ".   However, when I tried these instructions it was a fail. 

    I have attached a test file with the trigger as the AI described.  I have hidden box on the slide that should appear 2 seconds before the slide ends.  I have tried both -2" and -2000 and get the same result when I preview the slide...  the box appears at the end of the timeline.

    I'll see if JScode can get this working.

    • ThierryEMMANUEL's avatar
      ThierryEMMANUEL
      Community Member

      Hi Daniel. I will explore it tomorrow morning, because it is late here now (in France) :-) 

  • Hi DanielChodos I'm pleased to announce that I did it! In fact, ChapGPT did all the work. 😄 Let me explain.
    I was very surprised when I looked at your .story file. In all possible cases, SlideElapsedTime is only known at the END of the slide. “Elapsed” is a clue, even for me, who doesn't speak English very well. So, anticipating a temporal event based on an unknown final duration is... difficult.


    I just spent 3 hours this morning making Chappy sweat over the difficulty of finding the expected duration of the slide. He failed a dozen times. Finally, I suggested he look at the progress bar, since its scrolling speed automatically adapts to the final duration as soon as the slide starts. Indeed, in the debugging console, it has a “max” value of 5000 if the slide duration is 5s, 10000 if the duration is 10s, and so on. Chappy warmly congratulated me on this idea and I was very proud of it. The rest was pretty quick. 
    Everything works exactly as you want it to, I think, whatever the length of the slide. Even if you remove the progress bar! Give it a try. The timing (-2s, -5s) of the event is adjustable in the JScode. You can now duplicate this slide and change its duration in the timeline.
    Look at the .story file. It's all there: slides 2 and 3.
    I'd like to know if this works for you.

  • DanielChodos's avatar
    DanielChodos
    Community Member

    ThierryEMMANUEL thank you for your help with this.  The JScode works and the annotations are helpful to understand what parts are doing what.

    I did find an interesting anomaly with the functionality.  If you click on the seekbar and skip forward some, it breaks the timing and the EventTrigger variable changes by the amount that you change the seekbar.  This happens even if you reset the slide part way through.  BUT, if you let the slide play through once, it fixes itself.  This is very odd, but there are ways to preventing skipping around in the seekbar.

    • ThierryEMMANUEL's avatar
      ThierryEMMANUEL
      Community Member

      Hello DanielChodos . I'm very happy that your problem is “marked as solved”. I must confess that I tested the slides many times before sending you the file, but I hadn't tried to crash it! 😅 I couldn't quite reproduce the anomaly described, but it makes sense. The solution is to retrieve the duration of the slide (via the progress bar) but does not depend on the behavior of the bar. So, whatever you do with the bar, the duration is always (for example) 5s, and the event takes place at 5 minus 2s. And if you make the bar disappear: no bar, no bar manipulation, no problem.