# Cycling through custom areas

**URL:** <https://community.folivora.ai/t/cycling-through-custom-areas/13745>\
**Category:** Feature Requests\
**Created:** [February 17, 2020, 1:11pm UTC](https://community.folivora.ai/t/cycling-through-custom-areas/13745 "2020-02-17T13:11:55Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![coolwhiff](https://community.folivora.ai/user_avatar/community.folivora.ai/coolwhiff/32/12506_2.png) [@coolwhiff](https://community.folivora.ai/u/coolwhiff)\
**Post date:** [May 21, 2020, 7:42pm UTC](https://community.folivora.ai/t/cycling-through-custom-areas/13745/7 "2020-05-21T19:42:29Z")

</div>

Here's an improved, generalized version of this:

```
async function cycleThrough(triggers) {
  let cycleName = "cycle-" + triggers.join('-'); // Build a unique counter name
  let counterValue = await callBTT('get_number_variable', {variable_name: cycleName});

  // Initialize the value in BTT
  if(counterValue === undefined) {
	await callBTT('set_number_variable', {variable_name: cycleName, to: 0});
	counterValue = 0;
  }
    
  // Cycle through them
  let modCounter = counterValue % triggers.length;	
  callBTT('trigger_named_async_without_response', {trigger_name: triggers[modCounter]});
  
  // Increment the counter
  await callBTT('set_number_variable', {variable_name: cycleName, to: modCounter+1});

  // return to BTT
  returnToBTT(counterValue);

}

// Cycle through the given triggers
cycleThrough([
  "leftHalf",
  "leftTwoThirds",
  "leftOneThird"
]);

```

(You still have to create the referenced Reusable Named Triggers.)

@Andreas_Hegenberg: Is there some global place that helpers, like the `cycleThrough` could be added so that the trigger just becomes the usage of that method?

---

_[View the full topic](https://community.folivora.ai/t/cycling-through-custom-areas/13745)._
