Obtained Endings Screen Iteration Not Working [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
User avatar
chucklabs
Newbie
Posts: 3
Joined: Wed Feb 17, 2021 11:45 pm
Projects: re_Aegis
Contact:

Obtained Endings Screen Iteration Not Working [Solved]

#1 Post by chucklabs »

Hello! I'm having trouble with my obtained endings screen. I used this viewtopic.php?t=29242 post as reference, with some modified code.

My current code is:

Code: Select all

screen endings:
    tag menu
    use navigation

    $ all_endings = [(1, "firedOne", "Bad End 1 - Fired"), (2, "firedTwo", "Bad End 2 - Fired")]


    vbox:
        python:
            for i in (all_endings):
                ending_number = i[0]
                ending_name = i[1]
                ending_title = i[2]
                ending_string = "% 2d. ---------------------------------" % (ending_number)
                if ending_name in persistent.endings:
                    ending_string = "% 2d. %s" % (ending_number, ending_title)
                print ending_string
However, I'm getting the error that 'arument type of 'NoneType' is not iterable.' referring to the line "

Code: Select all

if ending_name in persistent.endings:
I'm only receiving this error when I navigate to the endings menu.
Last edited by chucklabs on Thu Feb 18, 2021 9:54 pm, edited 1 time in total.

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Obtained Endings Screen Iteration Not Working

#2 Post by hell_oh_world »

In your shared link there's a line that declares this persistent.endings.

Code: Select all

init python:
    
    # If persistent.endings is None (the first pass through the game), then make it a set.
    if persistent.endings is None:
        persistent.endings = set()
Also I would prefer, persistent.endings to be a list (persistent.endings = []) instead of a set (persistent.endings = set()) I guess. so you would use .append instead .add when adding an ending name and use .remove instead of .discard when removing an ending name. But that depends, if you don't want any duplicate endings then you're right about using a set, list doesn't care for duplicate items.

User avatar
chucklabs
Newbie
Posts: 3
Joined: Wed Feb 17, 2021 11:45 pm
Projects: re_Aegis
Contact:

Re: Obtained Endings Screen Iteration Not Working

#3 Post by chucklabs »

hell_oh_world wrote: Thu Feb 18, 2021 7:39 pm In your shared link there's a line that declares this persistent.endings.

Code: Select all

init python:
    
    # If persistent.endings is None (the first pass through the game), then make it a set.
    if persistent.endings is None:
        persistent.endings = set()
Also I would prefer, persistent.endings to be a list (persistent.endings = []) instead of a set (persistent.endings = set()) I guess. so you would use .append instead .add when adding an ending name and use .remove instead of .discard when removing an ending name. But that depends, if you don't want any duplicate endings then you're right about using a set, list doesn't care for duplicate items.
No more error now, thanks!

Post Reply

Who is online

Users browsing this forum: Amazon [Bot], jeffster, Silac