# Q: Move set of ticker update commands into CL script?

**URL:** <https://cl.desmos.com/t/q-move-set-of-ticker-update-commands-into-cl-script/4027>\
**Category:** Questions\
**Created:** [February 5, 2022, 4:30pm UTC](https://cl.desmos.com/t/q-move-set-of-ticker-update-commands-into-cl-script/4027 "2022-02-05T16:30:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raj](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/raj/32/5127_2.png) [@Raj](https://cl.desmos.com/u/Raj)\
**Post date:** [February 5, 2022, 4:30pm UTC](https://cl.desmos.com/t/q-move-set-of-ticker-update-commands-into-cl-script/4027/1 "2022-02-05T16:30:29Z")

</div>

Dear Desmos CL folks,

I’m trying to make a game involving getting points by catching a ball. Using a ticker graph-element, I can get variables to update, e.g. increase the score by 1 if the ball has been caught:

s\_core → s\_core+1 {c\_aught=1}

That’s fine, there are quite a few variables that I want to update, so the Run line next to the ticker ends up being a long unwieldy list of comma-separated updates that falls off the edge of the visible part of the screen. That’s inconvenient, and it also strikes me as likely to lead to bugs that will be hard to find and fix.

I’m guessing it ought to be possible to move some of that long list of ticker updates into the graph’s CL script, so that it’s easier to see, edit and keep them tidy. However, I haven’t been able to figure out how to do that. I get the impression that CL scripts themselves maybe can’t do condition-dependent variable updates? I’m not sure about that.

The only other way I know of to do condition-dependent updates is via actions that execute when the user clicks on something, but I want these updates to happen automatically, without requiring any user input.

Is that possible? Or do I need to squish all the desired updates into one long multi-comma ticker run-line?

Any help greatly appreciated!

Raj

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [February 5, 2022, 6:01pm UTC](https://cl.desmos.com/t/q-move-set-of-ticker-update-commands-into-cl-script/4027/2 "2022-02-05T18:01:18Z")

</div>

```auto
when condition result 
when condition result .... 
otherwise result

```

is the general format for conditionals in the CL.

In a graph

```auto
{condition: result when true, result when false}

```

Neither though have the iteration capabilities of actions (e.g. you can’t just add 1 to a variable without having a way of storing the initial and end values).

---

<div class="post-metadata">

**Author:** ![pirsquared](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@pirsquared](https://cl.desmos.com/u/pirsquared)\
**Post date:** [February 5, 2022, 8:18pm UTC](https://cl.desmos.com/t/q-move-set-of-ticker-update-commands-into-cl-script/4027/3 "2022-02-05T20:18:54Z")

</div>

Maybe not a perfect solution, but you _can_ give names to actions, and then call those names from the ticker.

So if you had your actions defined as

```auto
A=s_core->s_core+1 {c_aught=1}
B=.... {....}
C=....

```

then your ticker line is simply `A,B,C` - and editing individual actions is much, much neater.

---

<div class="post-metadata">

**Author:** ![Raj](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/raj/32/5127_2.png) [@Raj](https://cl.desmos.com/u/Raj)\
**Post date:** [February 6, 2022, 12:06pm UTC](https://cl.desmos.com/t/q-move-set-of-ticker-update-commands-into-cl-script/4027/4 "2022-02-06T12:06:35Z")

</div>

Thanks, that’s a very useful summary. Much appreciated!

---

<div class="post-metadata">

**Author:** ![Raj](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/raj/32/5127_2.png) [@Raj](https://cl.desmos.com/u/Raj)\
**Post date:** [February 6, 2022, 12:07pm UTC](https://cl.desmos.com/t/q-move-set-of-ticker-update-commands-into-cl-script/4027/5 "2022-02-06T12:07:57Z")

</div>

Thanks!! That is super useful. I have wanted for a long time to be able to separate out such actions into something like functions or procedures, but I haven’t known how to, until now. Thanks again!

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [February 6, 2022, 5:27pm UTC](https://cl.desmos.com/t/q-move-set-of-ticker-update-commands-into-cl-script/4027/6 "2022-02-06T17:27:41Z")

</div>

Just to clarify in the graph, there’s no "when"s.

```auto
{ : , }

```
