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

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

when condition result 
when condition result .... 
otherwise result

is the general format for conditionals in the CL.

In a graph

{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).

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

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.

1 Like

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

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!

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

{  : , }
1 Like