# \[Script API Reference\] Get a programmer instrument positoin and name

**URL:** https://qa.fmod.com/t/script-api-reference-get-a-programmer-instrument-positoin-and-name/16241
**Category:** FMOD Studio
**Created:** [September 30, 2020, 5:12am UTC](https://qa.fmod.com/t/script-api-reference-get-a-programmer-instrument-positoin-and-name/16241 "2020-09-30T05:12:58Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![yuqyu](https://avatars.discourse-cdn.com/v4/letter/y/eb8c5e/32.png) [@yuqyu](https://qa.fmod.com/u/yuqyu)
#### Post date: [September 30, 2020, 5:12am UTC](https://qa.fmod.com/t/script-api-reference-get-a-programmer-instrument-positoin-and-name/16241/1 "2020-09-30T05:12:58Z")

</div>

Hi, I want to make a script for FMOD Studio(2.0), get all the programmer instrument (quantities: 50+)position and name, So I can make them to trigger some timline events in game, is it possible?  
Thanks a lot.

---

<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: [October 6, 2020, 4:32am UTC](https://qa.fmod.com/t/script-api-reference-get-a-programmer-instrument-positoin-and-name/16241/2 "2020-10-06T04:32:49Z")

</div>

You can do this within FMOD Studio with a script such as the following

```
events.forEach(function(event) {
  programmerInstruments = [];
  instruments = event.timeline.modules;
  instruments.forEach(function(inst) {
    if (inst.entity === "ProgrammerSound") {
      programmerInstruments.push(inst);
    }
  })
  programmerInstruments.forEach(function(programmerInst){
    console.log(event.name + "\r\n " + programmerInst.name + ": " + programmerInst.start);
  })
})

```

If this is something you are performing at runtime, you can just call `Studio::EventInstance::getTimelinePosition()` at the time you are setting the programmer instruments sound.

[https://www.fmod.com/resources/documentation-api?version=2.1&page=studio-api-eventinstance.html#studio\_eventinstance\_gettimelineposition](https://www.fmod.com/resources/documentation-api?version=2.1&page=studio-api-eventinstance.html#studio_eventinstance_gettimelineposition)

---

<div class="post-metadata">

### Author: ![yuqyu](https://avatars.discourse-cdn.com/v4/letter/y/eb8c5e/32.png) [@yuqyu](https://qa.fmod.com/u/yuqyu)
#### Post date: [October 16, 2020, 8:10am UTC](https://qa.fmod.com/t/script-api-reference-get-a-programmer-instrument-positoin-and-name/16241/3 "2020-10-16T08:10:08Z")

</div>

Thx, it works!  
So, how Can I know when does the instrument stop?

---

<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: [October 20, 2020, 12:29am UTC](https://qa.fmod.com/t/script-api-reference-get-a-programmer-instrument-positoin-and-name/16241/4 "2020-10-20T00:29:00Z")

</div>

You will need to add `(programmerInst.start + programmerInst.length)` to the last `forEach` console output.

---

<div class="post-metadata">

### Author: ![yuqyu](https://avatars.discourse-cdn.com/v4/letter/y/eb8c5e/32.png) [@yuqyu](https://qa.fmod.com/u/yuqyu)
#### Post date: [October 21, 2020, 9:01am UTC](https://qa.fmod.com/t/script-api-reference-get-a-programmer-instrument-positoin-and-name/16241/5 "2020-10-21T09:01:01Z")

</div>

Thanks a lot!  
Where can i get these function info？  
[https://www.fmod.com/resources/documentation-studio?version=2.1&page=scripting-api-reference-project.html](https://www.fmod.com/resources/documentation-studio?version=2.1&page=scripting-api-reference-project.html)  
I didn’t find these Programmerinstrument function in the document.

---

<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: [October 26, 2020, 10:43pm UTC](https://qa.fmod.com/t/script-api-reference-get-a-programmer-instrument-positoin-and-name/16241/6 "2020-10-26T22:43:01Z")

</div>

The `programmerInst` is a variable that’s instantiated when you call the `forEach()` function. `programmerInst` is the current programmer instrument whilst looping through the `programmerInstruments` array.

This is more of a Javascript/coding issue than an FMOD Studio scripting API issue.
