Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Possible to use elif in draw image [x]?

Hello everyone,

I had a question about the functionality of the draw image function. To my understanding you can use this function like:

draw image center=1 file="[pic1]" scale=1 show_if=always x="[=-256 if 'left' in var.pos1 else 256]" y="[=-192 if 'top' in var.pos1 else 192]" z_index=

More specifically, I am interested in potentially being able to add an elif statement somewhere in between the if and else statements. I.e. x="[=-256 if 'left' in var.pos1 *** ADD IN ELIF HERE* else 256]". If i wanted to add an elif to this clause, would it be possible? I know there are sometimes syntax errors that occur and don't want to waste my time trying to start an experiment that can't be able to add an elif statement here.


Thank you in advance

Comments

  • Hi @twininator2 ,

    elif doesn't work in this context. However, you can use else if in these if-expressions:

    [=-256 if 'left' in var.pos1 else 0 if 'center' in var.pos1 else 256]
    

    Note that the expression inside (the ... in [=...] ) is just a regular Python expression, so anything that's syntactically valid a Python expression (i.e. something that evaluates to a value) works there as well.

    -- Sebastiaan

Sign In or Register to comment.