CSS extra coding

499 viewsCSS Questionsattributes
1

I see that CSS allows to use some coding inside action blocks. It works well when some condition, parsing code added there. But i see a problem with adding attributes. As there are not enough modifiers, and storing data outside is not comfortable, i would like to know:

Is there a way to store data inside CSS scripts?

ChatGPT is suggesting to add this code into an action:

if not hasattr(self, "_rec_blink_active"):
    self._rec_blink_active = False
if not self._rec_blink_active:
    self._rec_blink_active = True
    self.midi_cc_ch_0_val_16.send_value(57)

But this crushes ableton really hard so the reaction stop working correctly by parts or the whole reaction misses…

Only PC reboot helps.

So is there a way to add attributes and store data there? What is a correct way to do so if possible?

Hellem Answered question
0

You can add more modifiers directly in the script json file if you need to:

Is there anyway we can get more than 20 Modifiers?

Or simply write global variables in custom code: self.my_var = 1

We’re not able to support chatgpt or custom code but..
from what you have pasted there’s no indentation, which breaks python.

JohnC Posted new comment

wow!!! thats extra awesome!

I mean i used chat gpt to write code and then i implemented it into reactions actions body. No deep integration with chat gpt needed.

And about attributes: can you, please, provide an instructions how to declare them properly?
You have said that self.my_var = 1 is a global varibale, and where it can be putted? Like in a reaction action section? Show an example, please.

yes, i see that the code i inserted misses indentation – that happened due copy action to the forum here, thank you. There are indentations in the script i used. And it compiled properly.
But it act really strange… It just drops the action block with that code for attributes in action body (that was for clip_slot.is_recording) and started executing another action block (for clip_slot.is_playing)

“And about attributes: can you, please, provide an instructions how to declare them properly?”
Put them in the action section of an action block (switch the action to custom code, remove any code that’s in there then write your own)

thsnk you! Got success!!!! <3

Awesome!

How can we add a listeners to custom attributes stored?
Like self.my_var was updated?
As we actually can add a listeners for modifiers updated.
And how to do it with custom variables?

Attaching listeners to custom attributes is getting into pure Python coding not related to CSS.

Only modifiers can be used as listeners in CSS.
(Add more modifiers via the json file if you need more)

You are viewing 1 out of 3 answers, click here to view all answers.