Flicker rate conditions

PsychoPy version: Standalone, v2023.2.3

Hello, I am trying to get stimuli to flicker at different rates when presented. The experiment works when I hardcode the opacity to something like: (frameN % 12) >= 8, but I need the rate to change based on which stimulus is being presented. I tried putting the code for different flicker rates into the conditions file, but I get this error:

TypeError: Could not set alpha as value $(frameN % 12) >= 8 of type ‘str’

I have also tried without the $, as well as changing the appearance to ‘set every frame’ or ‘set every repeat’.

Am I doing something wrong or just going about this in the wrong way?
Any help would be very appreciated!