Items in the StoryParts class not going into any lists

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
verysunshine
Veteran
Posts: 339
Joined: Wed Sep 24, 2014 5:03 pm
Organization: Wild Rose Interactive
Contact:

Items in the StoryParts class not going into any lists

#1 Post by verysunshine »

I've based this code of this on Saguaro's Basic Message System. I hope to add radio buttons to switch parts. Right now, the parts don't appear in any list. I'm not sure where they are going, or how to debug the system. Any ideas?

Code: Select all

init python:
    class StoryPart(store.object):
        def __init__(self, title, labelto, slotgroup, d=False, choosable=True, read=False):
            self.labelto = labelto
            self.title = title
            self.slotgroup = slotgroup
            self.read = read
            self.d = d
            if choosable:
                self.givepart()
            else:
                if d:
                    storyline.append(self)
                else:
                    self.queue()
        
        def givepart(self):
            if self in parts_queue:
                parts_queue.remove(self)
            parts.append(self)
        
        def queue(self):
            parts_queue.append(self)
            
        def swappart(self):
            parts.append = storyline[self.slotgroup]
            storyline.append[self.slotgroup] = self
            parts.remove(self)
            renpy.restart_interaction()
            
    def addpart(self, title, labelto, slotgroup, d=False, choosable=True, read=False,):
            thispart = StoryPart(title, labelto, slotgroup, d=False, choosable=False, read=False)
            



screen StoryMenu:
    tag menu
    modal True
    zorder 15
    frame:
        padding (5,5)
        #height 300
        #style_group "mailbox"
        vbox:
            xalign 0.1
            spacing 5
            label "Parts Available"
            text "What shall you choose?" #temp text
            vbox:
                spacing 20
                viewport id "PartsList":
                    draggable True mousewheel True
                    vbox:
                        spacing 20
                        #style_prefix "radio"
                        for i in parts:
                            textbutton "(i.title)" action swappart()
                label "Other Parts"
                for i in parts_queue:
                    text "(i.title)" #action swappart()
                            
        vbox:
            yalign 1.0
            label "Story Sections"
            vbox:
                for i in storyline:
                    label "i.title"
                textbutton "Read Story" action Jump("story")

label start:
    $ parts = []
    $ parts_queue = []
    $ storyline = []
    
    $ addpart("The Cow", "thecow", 0, True)
    $ addpart("Stall", "thestall", 1, True)
    $ addpart("Hay", "thehay", 2, True)
    $ addpart("All", "thatsall", 3, True)
    $ addpart("Moose", "themoose", 0, False)
    $ addpart("Fred", "fred", 1, False)
    $ addpart("Juice", "thejuice", 2, False)

    scene bg room

    show eileen happy

    # These display lines of dialogue.

    e "You've created a new Ren'Py game."
    hide screen say
    show screen StoryMenu

    e "Once you add a story, pictures, and music, you can release it to the world!"

    # This ends the game.

    return
    
label thecow:
    "There once was a cow."
    return
    
label themoose:
    "There once was a moose."
    return
    
label thestall:
    "He lived in a stall."
    return
    
label fred:
    "His name was Fred."
    return
    
label thehay:
    "He ate hay."
    return
    
label thejuice:
    "He drank juice."
    return
    
label thatsall:
    "That's all."
    return

label story:
    hide screen StoryMenu
    e "Your story will go here."
    return

Build the basics first, then add all the fun bits.

Please check out my games on my itch.io page!

Post Reply

Who is online

Users browsing this forum: No registered users