Repeating Block Not Working?

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
User avatar
Kayotime
Regular
Posts: 37
Joined: Thu Jan 26, 2017 4:12 pm
Projects: Shinpaku High, Sakura Sunset
Location: America (US)
Contact:

Repeating Block Not Working?

#1 Post by Kayotime »

Code: Select all

    Koinu_Mood = " "
    Koinu_Status = " "
    
    Koinu_Happy = 0
    Koinu_Love = 0
    Koinu_Excited = 0
    Koinu_Brave = 0

Code: Select all

init -499 python:
    
    if (Koinu_Happy, Koinu_Love, Koinu_Excited, Koinu_Brave) == (-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5):
        
        Koinu_Mood = "Neutral"
        Koinu_Status = "Meh..."

    elif Koinu_Happy > 0 and Koinu_Happy > (Koinu_Love, Koinu_Excited, Koinu_Brave):
        
        if Koinu_Happy == 1:
            
            Koinu_Mood = "Pleased"
            Koinu_Status = "Well enough."
            
        elif Koinu_Happy == 2:
            
            Koinu_Mood = "Content"
            Koinu_Status = "Pretty good!"
            
        elif Koinu_Happy == 3:
            
            Koinu_Mood = "Happy"
            Koinu_Status = "Happily smiling!"
            
        elif Koinu_Happy == 4:
            
            Koinu_Mood = "Delighted"
            Koinu_Status = "LOL! ^w^"
            
        elif Koinu_Happy == 5:
            
            Koinu_Mood = "Ecstatic"
            Koinu_Status = "AWESOME SAUCE!!"
            
        elif Koinu_Happy > 5:
            
            Koinu_Happy = 5
            Koinu_Mood = "Ecstatic"
            Koinu_Status = "AWESOME SAUCE!!"
            
    elif Koinu_Happy < 0 and Koinu_Happy < (Koinu_Love, Koinu_Excited, Koinu_Brave):
        
        if Koinu_Happy == -1:
            
            Koinu_Mood = "Gloomy"
            Koinu_Status = "A little blue..."
            
        elif Koinu_Happy == -2:
            
            Koinu_Mood = "Hurt"
            Koinu_Status = "Hurting..."
            
        elif Koinu_Happy == -3:
            
            Koinu_Mood = "Sad"
            Koinu_Status = "Down in the dumps..."
            
        elif Koinu_Happy == -4:
            
            Koinu_Mood = "Forlorn"
            Koinu_Status = "About to cry..."
            
        elif Koinu_Happy == -5:
            
            Koinu_Mood = "Depressed"
            Koinu_Status = "Just kill me now..."
            
        elif Koinu_Happy < -5:
            
            Koinu_Happy = -5
            Koinu_Mood = "Depressed"
            Koinu_Status = "Just kill me now..."
            
    elif Koinu_Love > 0 and Koinu_Love > (Koinu_Happy, Koinu_Excited, Koinu_Brave):
        
        if Koinu_Love == 1:
            
            Koinu_Mood = "Flirty"
            Koinu_Status = "She's pretty cute..."
            
        elif Koinu_Love == 2:
            
            Koinu_Mood = "Affectionate"
            Koinu_Status = "Give me a hug!"
            
        elif Koinu_Love == 3:
            
            Koinu_Mood = "Romantic"
            Koinu_Status = "I think I'm in love!"
            
        elif Koinu_Love == 4:
            
            Koinu_Mood = "Alluring"
            Koinu_Status = "Give me a kiss!"
            
        elif Koinu_Love == 5:
            
            Koinu_Mood = "Irresistable"
            Koinu_Status = "Let's go back to my place! ♥‿♥"
            
        elif Koinu_Love > 5:
            
            Koinu_Love = 5
            Koinu_Mood = "Irresistable"
            Koinu_Status = "Let's go back to my place! ♥‿♥"
            
    elif Koinu_Love < 0 and Koinu_Love < (Koinu_Happy, Koinu_Excited, Koinu_Brave):
        
        if Koinu_Love == -1:
            
            Koinu_Mood = "Annoyed"
            Koinu_Status = "Grrr..."
            
        elif Koinu_Love == -2:
            
            Koinu_Mood = "Irritated"
            Koinu_Status = "Stop bugging me!"
            
        elif Koinu_Love == -3:
            
            Koinu_Mood = "Angry"
            Koinu_Status = "Go away!"
            
        elif Koinu_Love == -4:
            
            Koinu_Mood = "Furious"
            Koinu_Status = "Leave me alone!!!"
            
        elif Koinu_Love == -5:
            
            Koinu_Mood = "Livid"
            Koinu_Status = "I hate you!"
            
        elif Koinu_Love < -5:
            
            Koinu_Love = -5
            Koinu_Mood = "Livid"
            Koinu_Status = "I hate you!"
            
    elif Koinu_Excited > 0 and Koinu_Excited > (Koinu_Happy, Koinu_Love, Koinu_Brave):
        
        if Koinu_Excited == 1:
            
            Koinu_Mood = "Eager"
            Koinu_Status = "Let's go!"
            
        elif Koinu_Excited == 2:
            
            Koinu_Mood = "Perky"
            Koinu_Status = "Come on, come on, move it!"
            
        elif Koinu_Excited == 3:
            
            Koinu_Mood = "Excited"
            Koinu_Status = "Can't you keep up? Come on!"
            
        elif Koinu_Excited == 4:
            
            Koinu_Mood = "Restless"
            Koinu_Status = "I can't sit still! Let's GO!"
            
        elif Koinu_Excited == 5:
            
            Koinu_Mood = "Hyperactive"
            Koinu_Status = "Hyper, hyper, HYPEEEEEERRRRR!!!"
            
        elif Koinu_Excited > 5:
            
            Koinu_Excited = 5
            Koinu_Mood = "Hyperactive"
            Koinu_Status = "Hyper, hyper, HYPEEEEEERRRRR!!!"
            
    elif Koinu_Excited < 0 and Koinu_Excited < (Koinu_Happy, Koinu_Love, Koinu_Brave):
        
        if Koinu_Excited == -1:
            
            Koinu_Mood = "Bored"
            Koinu_Status = "This is boring...."
            
        elif Koinu_Excited == -2:
            
            Koinu_Mood = "Lazy"
            Koinu_Status = "Wake me when I care..."
            
        elif Koinu_Excited == -3:
            
            Koinu_Mood = "Tired"
            Koinu_Status = "*YAWN!* Oh, sorry... I'm just... tired."
            
        elif Koinu_Excited == -4:
            
            Koinu_Mood = "Exhausted"
            Koinu_Status = "Can't... take... another... step... ugh..."
            
        elif Koinu_Excited == -5:
            
            Koinu_Mood = "Lethargic"
            Koinu_Status = "ZZZZZzzzzz..."
            
        elif Koinu_Excited < -5:
            
            Koinu_Excited = -5
            Koinu_Mood = "Lethargic"
            Koinu_Status = "ZZZZZzzzzz..."
            
    elif Koinu_Brave > 0 and Koinu_Brave > (Koinu_Happy, Koinu_Love, Koinu_Excited):
        
        if Koinu_Brave == 1:
            
            Koinu_Mood = "Curious"
            Koinu_Status = "Oooo! What's that?!"
            
        elif Koinu_Brave == 2:
            
            Koinu_Mood = "Inspired"
            Koinu_Status = "Let's go do it!"
            
        elif Koinu_Brave == 3:
            
            Koinu_Mood = "Brave"
            Koinu_Status = "I'm not afraid! Come at me!"
            
        elif Koinu_Brave == 4:
            
            Koinu_Mood = "Determined"
            Koinu_Status = "I will never back down!"
            
        elif Koinu_Brave == 5:
            
            Koinu_Mood = "Heroic"
            Koinu_Status = "I'll save you! You're safe with me!"
            
        elif Koinu_Brave > 5:
            
            Koinu_Brave = 5
            Koinu_Mood = "Heroic"
            Koinu_Status = "I'll save you! You're safe with me!"
            
    elif Koinu_Brave < 0 and Koinu_Brave < (Koinu_Happy, Koinu_Love, Koinu_Excited):
        
        if Koinu_Brave == -1:
            
            Koinu_Mood = "Timid"
            Koinu_Status = "Wh-what? Uhmm...."
            
        elif Koinu_Brave == -2:
            
            Koinu_Mood = "Startled"
            Koinu_Status = "AH! Wh-what?! N-No!"
            
        elif Koinu_Brave == -3:
            
            Koinu_Mood = "Scared"
            Koinu_Status = "AHHH! STAY AWAY FROM ME!!"
            
        elif Koinu_Brave == -4:
            
            Koinu_Mood = "Terrified"
            Koinu_Status = "HEEEEEEEEEELP!"
            
        elif Koinu_Brave == -5:
            
            Koinu_Mood = "Traumatized"
            Koinu_Status = "............. AAAAAAAAAAHHHHHHHHHHHH!"
            
        elif Koinu_Brave < -5:
            
            Koinu_Brave = -5
            Koinu_Mood = "Traumatized"
            Koinu_Status = "............. AAAAAAAAAAHHHHHHHHHHHH!"
            
    repeat
Including the traceback.txt with this.

I don't understand why it's not working. All I want is for this huuuuuge block of code to be constantly rerun every time a user choice is made so that the data remains updated, but for some reason it isn't happening. Help!
Attachments
traceback.txt
The traceback.txt
(1.13 KiB) Downloaded 71 times
Active Project: Sakura Sunset
NOTICE: Shinpaku High is being put on hold for now. Sorry for the inconvenience!
Thank You!

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Repeating Block Not Working?

#2 Post by Divona »

"repeat" is for ATL, not Python.
Completed:
Image

User avatar
Kayotime
Regular
Posts: 37
Joined: Thu Jan 26, 2017 4:12 pm
Projects: Shinpaku High, Sakura Sunset
Location: America (US)
Contact:

Re: Repeating Block Not Working?

#3 Post by Kayotime »

Okay, well, then how do I get it to work the way I want? Is there an alternative? I'm not 100% good at coding...
Active Project: Sakura Sunset
NOTICE: Shinpaku High is being put on hold for now. Sorry for the inconvenience!
Thank You!

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Repeating Block Not Working?

#4 Post by Divona »

First, you will have to put all if/else code into a function.

Code: Select all

init python:
    def set_status():
        # the rest of the if/else code...
In "screens.rpy", search for "screen choice". There, you then call the function every time a choice is made:

Code: Select all

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            textbutton i.caption action [Function(set_status), i.action]
Something like this.
Completed:
Image

User avatar
Kayotime
Regular
Posts: 37
Joined: Thu Jan 26, 2017 4:12 pm
Projects: Shinpaku High, Sakura Sunset
Location: America (US)
Contact:

Re: Repeating Block Not Working?

#5 Post by Kayotime »

Okay, I'll try that and let you know if it worked.
Active Project: Sakura Sunset
NOTICE: Shinpaku High is being put on hold for now. Sorry for the inconvenience!
Thank You!

User avatar
Kayotime
Regular
Posts: 37
Joined: Thu Jan 26, 2017 4:12 pm
Projects: Shinpaku High, Sakura Sunset
Location: America (US)
Contact:

Re: Repeating Block Not Working?

#6 Post by Kayotime »

Code: Select all

## This is what you told me to put, right?

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            textbutton i.caption action [Function(set_status), i.action]

Code: Select all

init -1 python:
    
    ## These variables are for the Player data and
    ## have nothing to do with the moods of the 
    ## characters.
    
    Gender = " "
    Name = " "
    Pref = " "
    Pass = " "
    
    ## These are some other variables for Koinu
    ## that are NOT related to the moods, and
    ## therefore should be ignored in this case.
    
    Koinu = "????"
    Koinu_Rep = 0
    Koinu_Pref = "Straight"
    Koi_XP = 3
    Koi_XN = 0
    
    ## These two variables set Koinu's mood and status.
    ## There doesn't seem to be a problem here...
    
    Koinu_Mood = " "
    Koinu_Status = " "
    
    ## These four variables determine the values of each mood.
    ## Positive numbers indicate emotions related to the variable
    ## name (Happy, Romantic, Excited, Brave) and negative
    ## numbers indicate negative emotions related to the 
    ## variable (Sad, Angry, Tired, Scared). The traceback
    ## says that 'Koinu_Happy' is "referenced before
    ## assignment". Any idea what's wrong?
    
    Koinu_Happy = 0
    Koinu_Love = 0
    Koinu_Excited = 0
    Koinu_Brave = 0

## The following code is what you told me to do.
## Is the "if/then" code wrong? Or is there
## something else?
    
init python:
    
    def set_status():
        
        
        if (Koinu_Happy, Koinu_Love, Koinu_Excited, Koinu_Brave) == (-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5):
            
            Koinu_Mood = "Neutral"
            Koinu_Status = "Meh..."

        elif Koinu_Happy > 0 and Koinu_Happy > (Koinu_Love, Koinu_Excited, Koinu_Brave):
        
            if Koinu_Happy == 1:
            
                Koinu_Mood = "Pleased"
                Koinu_Status = "Well enough."
            
            elif Koinu_Happy == 2:
            
                Koinu_Mood = "Content"
                Koinu_Status = "Pretty good!"
            
            elif Koinu_Happy == 3:
            
                Koinu_Mood = "Happy"
                Koinu_Status = "Happily smiling!"
            
            elif Koinu_Happy == 4:
            
                Koinu_Mood = "Delighted"
                Koinu_Status = "LOL! ^w^"
            
            elif Koinu_Happy == 5:
            
                Koinu_Mood = "Ecstatic"
                Koinu_Status = "AWESOME SAUCE!!"
            
            elif Koinu_Happy > 5:
            
                Koinu_Happy = 5
                Koinu_Mood = "Ecstatic"
                Koinu_Status = "AWESOME SAUCE!!"
            
        elif Koinu_Happy < 0 and Koinu_Happy < (Koinu_Love, Koinu_Excited, Koinu_Brave):
        
            if Koinu_Happy == -1:
            
                Koinu_Mood = "Gloomy"
                Koinu_Status = "A little blue..."
            
            elif Koinu_Happy == -2:
            
                Koinu_Mood = "Hurt"
                Koinu_Status = "Hurting..."
            
            elif Koinu_Happy == -3:
            
                Koinu_Mood = "Sad"
                Koinu_Status = "Down in the dumps..."
            
            elif Koinu_Happy == -4:
            
                Koinu_Mood = "Forlorn"
                Koinu_Status = "About to cry..."
            
            elif Koinu_Happy == -5:
            
                Koinu_Mood = "Depressed"
                Koinu_Status = "Just kill me now..."
            
            elif Koinu_Happy < -5:
            
                Koinu_Happy = -5
                Koinu_Mood = "Depressed"
                Koinu_Status = "Just kill me now..."
            
        elif Koinu_Love > 0 and Koinu_Love > (Koinu_Happy, Koinu_Excited, Koinu_Brave):
        
            if Koinu_Love == 1:
            
                Koinu_Mood = "Flirty"
                Koinu_Status = "She's pretty cute..."
            
            elif Koinu_Love == 2:
            
                Koinu_Mood = "Affectionate"
                Koinu_Status = "Give me a hug!"
            
            elif Koinu_Love == 3:
            
                Koinu_Mood = "Romantic"
                Koinu_Status = "I think I'm in love!"
            
            elif Koinu_Love == 4:
            
                Koinu_Mood = "Alluring"
                Koinu_Status = "Give me a kiss!"
            
            elif Koinu_Love == 5:
            
                Koinu_Mood = "Irresistable"
                Koinu_Status = "Let's go back to my place! ♥‿♥"
            
            elif Koinu_Love > 5:
            
                Koinu_Love = 5
                Koinu_Mood = "Irresistable"
                Koinu_Status = "Let's go back to my place! ♥‿♥"
            
        elif Koinu_Love < 0 and Koinu_Love < (Koinu_Happy, Koinu_Excited, Koinu_Brave):
        
            if Koinu_Love == -1:
            
                Koinu_Mood = "Annoyed"
                Koinu_Status = "Grrr..."
            
            elif Koinu_Love == -2:
            
                Koinu_Mood = "Irritated"
                Koinu_Status = "Stop bugging me!"
            
            elif Koinu_Love == -3:
            
                Koinu_Mood = "Angry"
                Koinu_Status = "Go away!"
            
            elif Koinu_Love == -4:
            
                Koinu_Mood = "Furious"
                Koinu_Status = "Leave me alone!!!"
            
            elif Koinu_Love == -5:
            
                Koinu_Mood = "Livid"
                Koinu_Status = "I hate you!"
            
            elif Koinu_Love < -5:
            
                Koinu_Love = -5
                Koinu_Mood = "Livid"
                Koinu_Status = "I hate you!"
            
        elif Koinu_Excited > 0 and Koinu_Excited > (Koinu_Happy, Koinu_Love, Koinu_Brave):
        
            if Koinu_Excited == 1:
            
                Koinu_Mood = "Eager"
                Koinu_Status = "Let's go!"
            
            elif Koinu_Excited == 2:
            
                Koinu_Mood = "Perky"
                Koinu_Status = "Come on, come on, move it!"
            
            elif Koinu_Excited == 3:
            
                Koinu_Mood = "Excited"
                Koinu_Status = "Can't you keep up? Come on!"
            
            elif Koinu_Excited == 4:
            
                Koinu_Mood = "Restless"
                Koinu_Status = "I can't sit still! Let's GO!"
            
            elif Koinu_Excited == 5:
            
                Koinu_Mood = "Hyperactive"
                Koinu_Status = "Hyper, hyper, HYPEEEEEERRRRR!!!"
            
            elif Koinu_Excited > 5:
            
                Koinu_Excited = 5
                Koinu_Mood = "Hyperactive"
                Koinu_Status = "Hyper, hyper, HYPEEEEEERRRRR!!!"
            
        elif Koinu_Excited < 0 and Koinu_Excited < (Koinu_Happy, Koinu_Love, Koinu_Brave):
        
            if Koinu_Excited == -1:
            
                Koinu_Mood = "Bored"
                Koinu_Status = "This is boring...."
            
            elif Koinu_Excited == -2:
            
                Koinu_Mood = "Lazy"
                Koinu_Status = "Wake me when I care..."
            
            elif Koinu_Excited == -3:
            
                Koinu_Mood = "Tired"
                Koinu_Status = "*YAWN!* Oh, sorry... I'm just... tired."
            
            elif Koinu_Excited == -4:
            
                Koinu_Mood = "Exhausted"
                Koinu_Status = "Can't... take... another... step... ugh..."
            
            elif Koinu_Excited == -5:
            
                Koinu_Mood = "Lethargic"
                Koinu_Status = "ZZZZZzzzzz..."
            
            elif Koinu_Excited < -5:
            
                Koinu_Excited = -5
                Koinu_Mood = "Lethargic"
                Koinu_Status = "ZZZZZzzzzz..."
            
        elif Koinu_Brave > 0 and Koinu_Brave > (Koinu_Happy, Koinu_Love, Koinu_Excited):
        
            if Koinu_Brave == 1:
            
                Koinu_Mood = "Curious"
                Koinu_Status = "Oooo! What's that?!"
            
            elif Koinu_Brave == 2:
            
                Koinu_Mood = "Inspired"
                Koinu_Status = "Let's go do it!"
            
            elif Koinu_Brave == 3:
            
                Koinu_Mood = "Brave"
                Koinu_Status = "I'm not afraid! Come at me!"
            
            elif Koinu_Brave == 4:
            
                Koinu_Mood = "Determined"
                Koinu_Status = "I will never back down!"
            
            elif Koinu_Brave == 5:
            
                Koinu_Mood = "Heroic"
                Koinu_Status = "I'll save you! You're safe with me!"
            
            elif Koinu_Brave > 5:
            
                Koinu_Brave = 5
                Koinu_Mood = "Heroic"
                Koinu_Status = "I'll save you! You're safe with me!"
            
        elif Koinu_Brave < 0 and Koinu_Brave < (Koinu_Happy, Koinu_Love, Koinu_Excited):
        
            if Koinu_Brave == -1:
            
                Koinu_Mood = "Timid"
                Koinu_Status = "Wh-what? Uhmm...."
            
            elif Koinu_Brave == -2:
            
                Koinu_Mood = "Startled"
                Koinu_Status = "AH! Wh-what?! N-No!"
            
            elif Koinu_Brave == -3:
            
                Koinu_Mood = "Scared"
                Koinu_Status = "AHHH! STAY AWAY FROM ME!!"
            
            elif Koinu_Brave == -4:
            
                Koinu_Mood = "Terrified"
                Koinu_Status = "HEEEEEEEEEELP!"
            
            elif Koinu_Brave == -5:
            
                Koinu_Mood = "Traumatized"
                Koinu_Status = "............. AAAAAAAAAAHHHHHHHHHHHH!"
            
            elif Koinu_Brave < -5:
            
                Koinu_Brave = -5
                Koinu_Mood = "Traumatized"
                Koinu_Status = "............. AAAAAAAAAAHHHHHHHHHHHH!"
Including the traceback.txt file.

What did I do wrong?
Attachments
traceback.txt
(3.22 KiB) Downloaded 77 times
Active Project: Sakura Sunset
NOTICE: Shinpaku High is being put on hold for now. Sorry for the inconvenience!
Thank You!

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Repeating Block Not Working?

#7 Post by Divona »

My guess would be variables are not declared properly. Here is how it should look like:

Code: Select all

   
## These variables are for the Player data and
## have nothing to do with the moods of the 
## characters.
    
default Gender = " "
default Name = " "
default Pref = " "
default Pass = " "
    
## These are some other variables for Koinu
## that are NOT related to the moods, and
## therefore should be ignored in this case.
    
default Koinu = "????"
default Koinu_Rep = 0
default Koinu_Pref = "Straight"
default Koi_XP = 3
default Koi_XN = 0
    
## These two variables set Koinu's mood and status.
## There doesn't seem to be a problem here...
    
default Koinu_Mood = " "
default Koinu_Status = " "
    
## These four variables determine the values of each mood.
## Positive numbers indicate emotions related to the variable
## name (Happy, Romantic, Excited, Brave) and negative
## numbers indicate negative emotions related to the 
## variable (Sad, Angry, Tired, Scared). The traceback
## says that 'Koinu_Happy' is "referenced before
## assignment". Any idea what's wrong?
    
default Koinu_Happy = 0
default Koinu_Love = 0
default Koinu_Excited = 0
default Koinu_Brave = 0

## The following code is what you told me to do.
## Is the "if/then" code wrong? Or is there
## something else?
    
init python:
    
    def set_status():
        global Koinu_Mood, Koinu_Status
        global Koinu_Happy, Koinu_Love, Koinu_Excited, Koinu_Brave
        
        if (Koinu_Happy, Koinu_Love, Koinu_Excited, Koinu_Brave) == (-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5):
            
            Koinu_Mood = "Neutral"
            Koinu_Status = "Meh..."

        # and so on...
Completed:
Image

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Repeating Block Not Working?

#8 Post by Remix »

You might also want to explain what you are trying to accomplish with your tuple comparisons... I am sure someone will point you in the right direction.

For info:
Python does tuple comparison on a per element basis until a non draw result is found
For example:
Is (2,0,0) > (1,120,120,120,120) ? ....
True, yes it is, as (2 beats 1 ... the 120's are ignored as the first non draw result occured)

Your
if (Koinu_Happy, Koinu_Love, Koinu_Excited, Koinu_Brave) == (-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5)
is rationally the same as saying
if Koinu_Happy == -5 and Koinu_Love == -4 and Koinu_Excited == -3 and Koinu_Brave == -2:

So, perhaps say (in words) what each test is meant to do and hopefully someone will help
Frameworks & Scriptlets:

User avatar
Kayotime
Regular
Posts: 37
Joined: Thu Jan 26, 2017 4:12 pm
Projects: Shinpaku High, Sakura Sunset
Location: America (US)
Contact:

Re: Repeating Block Not Working?

#9 Post by Kayotime »

Okay, I've been meaning to get to replying but I've been busy with school so bear with me.

What I want to do is say that if "Koinu_Happy" equals "Koinu_Love" AND "Koinu_Excited" AND "Koinu_Brave" no matter what number on the -5 to 5 scale they are at, then "Koinu_Mood" equals "Neutral" and "Koinu_Status" equals "Meh..."

I think I may have fixed it based on what you told me:

Code: Select all

if Koinu_Happy == (Koinu_Love, Koinu_Excited, Koinu_Brave):
            
            Koinu_Mood = "Neutral"
            Koinu_Status = "Meh..."
From what you're telling me, this SHOULD equal "if Koinu_Happy == Koinu_Love and Koinu_Happy == Koinu_Excited and Koinu_Happy == Koinu_Brave" which is pretty much what I wanted in the first place. Essentially, I want it to be so that whenever all four variables equal the same number, then "Koinu_Mood" is set to "Neutral" and "Koinu_Status" is set to "Meh..."

However, even after doing this, I still get the same exact error. I'm including the traceback.txt file.

This is what I have in the "moods.rpy" file, which is separate from all the other files for organizational purposes:

Code: Select all

## Demo allows me to quickly test the features without having to go through the whole intro. It has nothing to do with Koinu's Moods.
default Demo = True
default Gender = " "
default Name = " "
default Pref = " "
default Pass = " "
    
default Koinu = "????"
default Koi_Rep = 0
default Koinu_Pref = "Straight"
default Koi_XP = 3
default Koi_XN = 0

default Koinu_Happy = 0
default Koinu_Love = 0
default Koinu_Excited = 0
default Koinu_Brave = 0

default Koinu_Mood = " "
default Koinu_Status = " "

init python:
    
    def set_status():
        global Koinu_Mood, Koinu_Status
        global Koinu_Happy, Koinu_Love, Koinu_Excited, Koinu_Brave
        
        if Koinu_Happy == (Koinu_Love, Koinu_Excited, Koinu_Brave):
            
            Koinu_Mood = "Neutral"
            Koinu_Status = "Meh..."

        elif Koinu_Happy > 0 and Koinu_Happy > (Koinu_Love, Koinu_Excited, Koinu_Brave):
        
            if Koinu_Happy == 1:
            
                Koinu_Mood = "Pleased"
                Koinu_Status = "Well enough."
            
            elif Koinu_Happy == 2:
            
                Koinu_Mood = "Content"
                Koinu_Status = "Pretty good!"
            
            elif Koinu_Happy == 3:
            
                Koinu_Mood = "Happy"
                Koinu_Status = "Happily smiling!"
            
            elif Koinu_Happy == 4:
            
                Koinu_Mood = "Delighted"
                Koinu_Status = "LOL! ^w^"
            
            elif Koinu_Happy == 5:
            
                Koinu_Mood = "Ecstatic"
                Koinu_Status = "AWESOME SAUCE!!"
            
            elif Koinu_Happy > 5:
            
                Koinu_Happy = 5
                Koinu_Mood = "Ecstatic"
                Koinu_Status = "AWESOME SAUCE!!"
            
        elif Koinu_Happy < 0 and Koinu_Happy < (Koinu_Love, Koinu_Excited, Koinu_Brave):
        
            if Koinu_Happy == -1:
            
                Koinu_Mood = "Gloomy"
                Koinu_Status = "A little blue..."
            
            elif Koinu_Happy == -2:
            
                Koinu_Mood = "Hurt"
                Koinu_Status = "Hurting..."
            
            elif Koinu_Happy == -3:
            
                Koinu_Mood = "Sad"
                Koinu_Status = "Down in the dumps..."
            
            elif Koinu_Happy == -4:
            
                Koinu_Mood = "Forlorn"
                Koinu_Status = "About to cry..."
            
            elif Koinu_Happy == -5:
            
                Koinu_Mood = "Depressed"
                Koinu_Status = "Just kill me now..."
            
            elif Koinu_Happy < -5:
            
                Koinu_Happy = -5
                Koinu_Mood = "Depressed"
                Koinu_Status = "Just kill me now..."
            
        elif Koinu_Love > 0 and Koinu_Love > (Koinu_Happy, Koinu_Excited, Koinu_Brave):
        
            if Koinu_Love == 1:
            
                Koinu_Mood = "Flirty"
                Koinu_Status = "She's pretty cute..."
            
            elif Koinu_Love == 2:
            
                Koinu_Mood = "Affectionate"
                Koinu_Status = "Give me a hug!"
            
            elif Koinu_Love == 3:
            
                Koinu_Mood = "Romantic"
                Koinu_Status = "I think I'm in love!"
            
            elif Koinu_Love == 4:
            
                Koinu_Mood = "Alluring"
                Koinu_Status = "Give me a kiss!"
            
            elif Koinu_Love == 5:
            
                Koinu_Mood = "Irresistable"
                Koinu_Status = "Let's go back to my place! ♥‿♥"
            
            elif Koinu_Love > 5:
            
                Koinu_Love = 5
                Koinu_Mood = "Irresistable"
                Koinu_Status = "Let's go back to my place! ♥‿♥"
            
        elif Koinu_Love < 0 and Koinu_Love < (Koinu_Happy, Koinu_Excited, Koinu_Brave):
        
            if Koinu_Love == -1:
            
                Koinu_Mood = "Annoyed"
                Koinu_Status = "Grrr..."
            
            elif Koinu_Love == -2:
            
                Koinu_Mood = "Irritated"
                Koinu_Status = "Stop bugging me!"
            
            elif Koinu_Love == -3:
            
                Koinu_Mood = "Angry"
                Koinu_Status = "Go away!"
            
            elif Koinu_Love == -4:
            
                Koinu_Mood = "Furious"
                Koinu_Status = "Leave me alone!!!"
            
            elif Koinu_Love == -5:
            
                Koinu_Mood = "Livid"
                Koinu_Status = "I hate you!"
            
            elif Koinu_Love < -5:
            
                Koinu_Love = -5
                Koinu_Mood = "Livid"
                Koinu_Status = "I hate you!"
            
        elif Koinu_Excited > 0 and Koinu_Excited > (Koinu_Happy, Koinu_Love, Koinu_Brave):
        
            if Koinu_Excited == 1:
            
                Koinu_Mood = "Eager"
                Koinu_Status = "Let's go!"
            
            elif Koinu_Excited == 2:
            
                Koinu_Mood = "Perky"
                Koinu_Status = "Come on, come on, move it!"
            
            elif Koinu_Excited == 3:
            
                Koinu_Mood = "Excited"
                Koinu_Status = "Can't you keep up? Come on!"
            
            elif Koinu_Excited == 4:
            
                Koinu_Mood = "Restless"
                Koinu_Status = "I can't sit still! Let's GO!"
            
            elif Koinu_Excited == 5:
            
                Koinu_Mood = "Hyperactive"
                Koinu_Status = "Hyper, hyper, HYPEEEEEERRRRR!!!"
            
            elif Koinu_Excited > 5:
            
                Koinu_Excited = 5
                Koinu_Mood = "Hyperactive"
                Koinu_Status = "Hyper, hyper, HYPEEEEEERRRRR!!!"
            
        elif Koinu_Excited < 0 and Koinu_Excited < (Koinu_Happy, Koinu_Love, Koinu_Brave):
        
            if Koinu_Excited == -1:
            
                Koinu_Mood = "Bored"
                Koinu_Status = "This is boring...."
            
            elif Koinu_Excited == -2:
            
                Koinu_Mood = "Lazy"
                Koinu_Status = "Wake me when I care..."
            
            elif Koinu_Excited == -3:
            
                Koinu_Mood = "Tired"
                Koinu_Status = "*YAWN!* Oh, sorry... I'm just... tired."
            
            elif Koinu_Excited == -4:
            
                Koinu_Mood = "Exhausted"
                Koinu_Status = "Can't... take... another... step... ugh..."
            
            elif Koinu_Excited == -5:
            
                Koinu_Mood = "Lethargic"
                Koinu_Status = "ZZZZZzzzzz..."
            
            elif Koinu_Excited < -5:
            
                Koinu_Excited = -5
                Koinu_Mood = "Lethargic"
                Koinu_Status = "ZZZZZzzzzz..."
            
        elif Koinu_Brave > 0 and Koinu_Brave > (Koinu_Happy, Koinu_Love, Koinu_Excited):
        
            if Koinu_Brave == 1:
            
                Koinu_Mood = "Curious"
                Koinu_Status = "Oooo! What's that?!"
            
            elif Koinu_Brave == 2:
            
                Koinu_Mood = "Inspired"
                Koinu_Status = "Let's go do it!"
            
            elif Koinu_Brave == 3:
            
                Koinu_Mood = "Brave"
                Koinu_Status = "I'm not afraid! Come at me!"
            
            elif Koinu_Brave == 4:
            
                Koinu_Mood = "Determined"
                Koinu_Status = "I will never back down!"
            
            elif Koinu_Brave == 5:
            
                Koinu_Mood = "Heroic"
                Koinu_Status = "I'll save you! You're safe with me!"
            
            elif Koinu_Brave > 5:
            
                Koinu_Brave = 5
                Koinu_Mood = "Heroic"
                Koinu_Status = "I'll save you! You're safe with me!"
            
        elif Koinu_Brave < 0 and Koinu_Brave < (Koinu_Happy, Koinu_Love, Koinu_Excited):
        
            if Koinu_Brave == -1:
            
                Koinu_Mood = "Timid"
                Koinu_Status = "Wh-what? Uhmm...."
            
            elif Koinu_Brave == -2:
            
                Koinu_Mood = "Startled"
                Koinu_Status = "AH! Wh-what?! N-No!"
            
            elif Koinu_Brave == -3:
            
                Koinu_Mood = "Scared"
                Koinu_Status = "AHHH! STAY AWAY FROM ME!!"
            
            elif Koinu_Brave == -4:
            
                Koinu_Mood = "Terrified"
                Koinu_Status = "HEEEEEEEEEELP!"
            
            elif Koinu_Brave == -5:
            
                Koinu_Mood = "Traumatized"
                Koinu_Status = "............. AAAAAAAAAAHHHHHHHHHHHH!"
            
            elif Koinu_Brave < -5:
            
                Koinu_Brave = -5
                Koinu_Mood = "Traumatized"
                Koinu_Status = "............. AAAAAAAAAAHHHHHHHHHHHH!"
This is what I have in the "screens.rpy" file, in order to have the function called every time an option is clicked:

Code: Select all

## Choice screen ###############################################################
##
## This screen is used to display the in-game choices presented by the menu
## statement. The one parameter, items, is a list of objects, each with caption
## and action fields.
##
## http://www.renpy.org/doc/html/screen_special.html#choice

## This is what you told me to put, right?

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            textbutton i.caption action [Function(set_status), i.action]
And yet, I still get the error as shown in the "traceback.txt" file.

Here is a little walkthrough of what happens in the game with all the scripting set to what I've already shown you:

1. I run the test.
2. The main menu comes up without a problem.
3. I click "Start".
4. The game starts without a problem.
5. The first set of menu options come up with the dialogue prompt. No problems.
6. I click on either menu choice. Doesn't matter which one.
7. Before the menu choice takes me where it is coded to go to, the game crashes and I get the error.
8. Error is "Koinu_Happy referenced before assignment." I have no idea what that means.
9. I close the game and take a look at the code. I'm too inexperienced to see a problem.
10. I come here looking for answers. :(

Please help me!
Attachments
traceback.txt
The traceback.txt file
(3.22 KiB) Downloaded 77 times
Active Project: Sakura Sunset
NOTICE: Shinpaku High is being put on hold for now. Sorry for the inconvenience!
Thank You!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]