Page 1 of 1

Substraction of variables help (SOLVED)

Posted: Thu Oct 20, 2016 10:30 am
by oro121
Hello guys, I'm trying to make a condition where subsrtaction of two variables more than a value. I tried this, but it didn't work. How to do it right?

Code: Select all

    if $ process == True and ($ monthcount -= $ timeprocess) >= 3:
        $ process == False
        $ period == 0
        text "Вы создали ингредиент."
    else: 
        text "---------------"
    call tim
P.S
How to substract one variable from another?

Re: Substraction of variables help

Posted: Thu Oct 20, 2016 10:48 am
by papiersam
Omit cash sign in statements:

Code: Select all

    if process == True and ( monthcount -= timeprocess >= 3):
        $ process == False
        $ period == 0
        text "Вы создали ингредиент."
    else: 
        text "---------------"
    call tim

Re: Substraction of variables help

Posted: Fri Oct 21, 2016 12:07 am
by oro121
It seems i'm still doing something wrong. The first line of the condition causes syntax error. I'm curious if is it possible to make an expression in a condition?

Re: Substraction of variables help

Posted: Fri Oct 21, 2016 1:27 am
by Ocelot
IIRC assignment in Python is a statement, not an expression, and cannot be part of expressions.

Re: Substraction of variables help

Posted: Fri Oct 21, 2016 2:29 am
by oro121
I found the solution.

Code: Select all

            $ subtime = monthcount - period
    if process == True and subtime >= timeprocess1:
        $ process = False
        $ period = 0
        "[process]"
        "Вы создали ингредиент."
    else: 
        "---------------"
        nvl clear
    call tim
Just need to make a variable of substraction right before condition and it works perfectly.