# Execute Javascript when an Event starts palying

**URL:** <https://qa.fmod.com/t/execute-javascript-when-an-event-starts-palying/16862>\
**Category:** FMOD Engine\
**Created:** [March 11, 2021, 8:59pm UTC](https://qa.fmod.com/t/execute-javascript-when-an-event-starts-palying/16862 "2021-03-11T20:59:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![snoooze39](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@snoooze39](https://qa.fmod.com/u/snoooze39)\
**Post date:** [March 11, 2021, 8:59pm UTC](https://qa.fmod.com/t/execute-javascript-when-an-event-starts-palying/16862/1 "2021-03-11T20:59:13Z")

</div>

I am trying to do calculations on a game parameter in Fmod Script, read parameter A to set cursor position on parameter B.  
I managed ot modify the Engine Designer script to lookup the right parameter value and do the calculation but I cannot figure out how to exectue the function other than click it in the menu.

How can I exectue the script when the event starts to play?

Sorry if this is a stupid question… total JavaScript noob here and I can’t seem to find any examples except the ones that come with Studio.

---

<div class="post-metadata">

**Author:** ![Alcibiade](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/alcibiade/32/4284_2.png) [@Alcibiade](https://qa.fmod.com/u/Alcibiade)\
**Post date:** [March 11, 2021, 9:34pm UTC](https://qa.fmod.com/t/execute-javascript-when-an-event-starts-palying/16862/2 "2021-03-11T21:34:59Z")

</div>

What’s the trigger where the calculation and the set cursor position should be made?

---

<div class="post-metadata">

**Author:** ![snoooze39](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@snoooze39](https://qa.fmod.com/u/snoooze39)\
**Post date:** [March 11, 2021, 9:45pm UTC](https://qa.fmod.com/t/execute-javascript-when-an-event-starts-palying/16862/3 "2021-03-11T21:45:46Z")

</div>

The defaul Engine Designer script creates a Menue item and is triggered when the menue item is clicked.

It’s all the same code, I just change the calculations in the timer loop near the bottom.

Is there a way to start a timer without the menue so it just starts as soon as the script is loaded?  
I can’t find a timer mentioned any other place in the API documentation.

---

<div class="post-metadata">

**Author:** ![richard\_simms](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/richard_simms/32/261_2.png) [@richard\_simms](https://qa.fmod.com/u/richard_simms)\
**Post date:** [March 17, 2021, 12:46am UTC](https://qa.fmod.com/t/execute-javascript-when-an-event-starts-palying/16862/4 "2021-03-17T00:46:58Z")

</div>

It’s currently not possible to execute scripts other than by either calling it in the Script’s menu, or by callbacks (currently only on build started, build finished, and audio file imported).
