Substraction of variables help (SOLVED)

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
oro121
Newbie
Posts: 10
Joined: Wed Aug 21, 2013 1:33 am
Location: Russia
Contact:

Substraction of variables help (SOLVED)

#1 Post by oro121 » Thu Oct 20, 2016 10:30 am

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?
Last edited by oro121 on Fri Oct 21, 2016 2:30 am, edited 2 times in total.

User avatar
papiersam
Veteran
Posts: 231
Joined: Fri Aug 12, 2016 2:24 pm
Completed: Gem Hunt Beta, 1/Probably, Animunch
Projects: The Panda Who Dreamed
Contact:

Re: Substraction of variables help

#2 Post by papiersam » Thu Oct 20, 2016 10:48 am

Omit cash sign in statements:

Code: Select all

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

oro121
Newbie
Posts: 10
Joined: Wed Aug 21, 2013 1:33 am
Location: Russia
Contact:

Re: Substraction of variables help

#3 Post by oro121 » Fri Oct 21, 2016 12:07 am

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?

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1883
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Substraction of variables help

#4 Post by Ocelot » Fri Oct 21, 2016 1:27 am

IIRC assignment in Python is a statement, not an expression, and cannot be part of expressions.
< < insert Rick Cook quote here > >

oro121
Newbie
Posts: 10
Joined: Wed Aug 21, 2013 1:33 am
Location: Russia
Contact:

Re: Substraction of variables help

#5 Post by oro121 » Fri Oct 21, 2016 2:29 am

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.

Post Reply

Who is online

Users browsing this forum: Google [Bot], _ticlock_