Codex Issues (Of sorts) [UNSOLVED]

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
Gryphbear
Regular
Posts: 91
Joined: Wed Jun 16, 2010 11:45 pm
Contact:

Codex Issues (Of sorts) [UNSOLVED]

#1 Post by Gryphbear »

I wanna thank the people on Discord for helping me get this far. Minute, and seibalyi :)

I'm sort of trying to create a codex to track down Character relationships, the character you're playing as, and information on other characters. So far, I've got this - it loads as a call screen page_select() in script.rpy.

It loads the menu tabs without a problem. I can click on them all. But ONLY the "Exit" button works. The rest do not even display 'any' content into the space to the right of the column of menu choices.

I've included all the code that I managed to kludge together thanks to those two's help.

Code: Select all

default screen_page = "containerScreen" #I'm guessing this sets a variable, so it will find which 'page' you're on. 

screen page_select():

    style_prefix "myScreen"
    frame:
        has vbox
        xminimum 150 ymaximum 30
        textbutton "Personal Info" action SetScreenVariable(screen_page, "character_stat")
        textbutton "Connections" action SetScreenVariable(screen_page, "connection_stat")
        textbutton "Characters" action SetScreenVariable(screen_page, "character_bios")
        textbutton "Exit" action Return()

style myScreen_frame is frame:
    background Frame("gui/textbox.png")
    
style myScreen_button is button:
    xminimum 150 ymaximum 40
    idle_background Frame("gui/button/choice_idle_background.png")
    hover_background Frame("gui/button/choice_hover_background.png")
                   
screen containerScreen():

    fixed:
        if screen_page == "character_stat":         
            use character_stat
        elif screen_page == "connection_stat":
            use connection_stat
        else: 
            use character_bios
    use page_select

screen character_stat():
       frame: 
           
           xalign 0.2 yalign 0.0
           vbox:
               text "Name: [m.name]"
#            hbox: 
#               xalign 0.5 yalign 0.8             
#               textbutton "Return":
#                   action Hide("character_stat")

screen connection_stat():
    frame:
        xalign 0.2 yalign 0.0
        vbox: 
          
            text "Connection to Characters"
#        hbox: 
#            xalign 0.5 yalign 0.8
#            textbutton "Return":
#                action Hide("connection_stat")
                
screen character_bios():
    frame:
        xalign 0.2 yalign 0.0
        vbox: 
            text "Character Bios"
#        hbox: 
#            xalign 0.5 yalign 0.8
#            textbutton "Return":
#                action Hide("character_bios")
So I guess I'd like to find out *why* it won't display the info in each of the screens into that big screen. Am I missing something?

Thanks for the help.
Last edited by Gryphbear on Sat Aug 11, 2018 4:38 pm, edited 2 times in total.
WIP: Ring av Guder - (Contemporary Fantasy VN/Dating Sim?)

What do you get when you inherit a mystical ring, meet Norse Dieties, and Werewolves, Satyrs, or Dwarves? Possibilities.

General Completion: 5% - (Still working on story plot.)
Story status: 1% (In progress of revamping)
Scripting: 1% (Prologue is about done)
Character Art: 0% (Would like to find a Bara-type Artist, but will learn to draw them myself if necessary)
BG/CG's: 0% (None so far)

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Codex Issues (Of sorts)

#2 Post by xavimat »

The variable "screen_page" is local to the screen, so changes in screen page_select won't affect the if/elif in containerScreen.

You can just merge the two screens in one:

Code: Select all

screen containerScreen():

    default screen_page = "character_stat"

    style_prefix "myScreen"

    if screen_page == "character_stat":         
        use character_stat
    elif screen_page == "connection_stat":
        use connection_stat
    else: 
        use character_bios

    frame:
        has vbox
        xminimum 150 ymaximum 30
        textbutton "Personal Info" action SetScreenVariable("screen_page", "character_stat")
        textbutton "Connections" action SetScreenVariable("screen_page", "connection_stat")
        textbutton "Characters" action SetScreenVariable("screen_page", "character_bios")
        textbutton "Exit" action Return()
- I've added the default line
- You don't need the "fixed".
- EDIT: missing quotes on SetScreenVariable("screen_page"...
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
Gryphbear
Regular
Posts: 91
Joined: Wed Jun 16, 2010 11:45 pm
Contact:

Re: Codex Issues (Of sorts)

#3 Post by Gryphbear »

Thank you for your help! Menu is fixed and working. For those of you that try to copy this - the screen_page variable in SetScreenVariable needs to be encased in " "'s. Here's also the updated (and full) code for those who might want to do something similar.

Code: Select all

screen containerScreen():

    default screen_page = "character_stat"

    style_prefix "myScreen"

    if screen_page == "character_stat":         
        use character_stat
    elif screen_page == "connection_stat":
        use connection_stat
    else: 
        use character_bios
    # I imagine you could add "More" content pages to this by adding more 'elif' conditions and the last one being the last codex entry. 
    frame:
        has vbox
        xminimum 150 ymaximum 30
        textbutton "Personal Info" action SetScreenVariable("screen_page", "character_stat")
        textbutton "Connections" action SetScreenVariable("screen_page", "connection_stat")
        textbutton "Characters" action SetScreenVariable("screen_page", "character_bios")
        textbutton "Exit" action Return()
    # you define all your codex entries here, and an 'exit' button. 
style myScreen_frame is frame:
    background Frame("gui/textbox.png") # replace with your own bg - same with the idle/hover bgs below.
    
style myScreen_button is button:
    xminimum 150 ymaximum 40
    idle_background Frame("gui/button/choice_idle_background.png")
    hover_background Frame("gui/button/choice_hover_background.png")
                   
screen character_stat():
       frame: 
           
           xalign 0.2 yalign 0.0
           vbox:
               text "Name: [m.name]" # Example

screen connection_stat():
    frame:
        xalign 0.2 yalign 0.0
        vbox: 
          
            text "Connections"

                
screen character_bios():
    frame:
        xalign 0.2 yalign 0.0
        vbox: 
            text "Character Bios"

Hope my code will be of some help. You call it via call screen containerScreen() where you want the menu to appear.
WIP: Ring av Guder - (Contemporary Fantasy VN/Dating Sim?)

What do you get when you inherit a mystical ring, meet Norse Dieties, and Werewolves, Satyrs, or Dwarves? Possibilities.

General Completion: 5% - (Still working on story plot.)
Story status: 1% (In progress of revamping)
Scripting: 1% (Prologue is about done)
Character Art: 0% (Would like to find a Bara-type Artist, but will learn to draw them myself if necessary)
BG/CG's: 0% (None so far)

User avatar
Gryphbear
Regular
Posts: 91
Joined: Wed Jun 16, 2010 11:45 pm
Contact:

Re: Codex Issues (Of sorts) [UNSOLVED]

#4 Post by Gryphbear »

Okay. I sort of tweaked my Codex again, and essentially wanted to sort of add a transparency to the frame, but only the default page is getting that style. The rest of it is not. Content will change eventually.

Here's the code as I have it so far.

Code: Select all

screen codex_button():
    tag menu
    frame:
        
        background "darkslategray"
        textbutton "Codex" action ShowMenu("containerScreen") 
        
    
screen containerScreen():

    default screen_page = "character_stat"
    tag menu
    style_prefix "myScreen"

    if screen_page == "character_stat":         
        use character_stat
    elif screen_page == "connection_stat":
        use connection_stat
    else: 
        use character_bios

    frame:
        has vbox
        xminimum 150 ymaximum 30
        textbutton "Personal Info" action SetScreenVariable("screen_page", "character_stat")
        textbutton "Connections" action SetScreenVariable("screen_page", "connection_stat")
        textbutton "Characters" action SetScreenVariable("screen_page", "character_bios")
        textbutton "Exit" action Return()

style myScreen_button is button
style myScreen_button:
    xminimum 150 ymaximum 40
    idle_background Frame("gui/button/choice_idle_background.png")
    hover_background Frame("gui/button/choice_hover_background.png")

style myScreen_frame is frame
style myScreen_frame:
    background Frame("#444444B3") # Decided to add transparency codes.
    # background Frame("gui/textbox.png")
    
screen character_stat(): # Only this screen gets the frame color I've set.
       frame: 
           xalign 0.5
           vbox:
               xalign 0.15 yalign 0.03
               text "Name: [m.name]"
               if m.reputation > 50:
                   text "Reputation: Good"
               elif m.reputation < 50:
                   text "Reputation: Bad"
               else:
                   text "Reputation: Neutral"
               if m.adventurer:
                   text "Job: Adventurer"
               elif m.cleric: 
                   text "Job: Cleric"
               else:
                   text "Job: [m.job]"
           
           vbox:
               xalign 1.0 yalign 0.0
               label "Mood:"
               label "Annoyance: [m.annoyed]"
               label "Disappointment: [m.disappoint]"
               label "Afraid: [m.fear]"
               label "Guilt: [m.guilt]"
               label "Happy: [m.happy]"
               label "Sad: [m.sad]"
               label "Angry: [m.angry]"
               label "Disgust: [m.disgust]"
               label "Lust: [m.lust]"
           
           vbox: 
               xalign 0.7 yalign 0.0
               label "Tendencies:"
               label "Reckless: [m.reckless]"
               label "Persistence: [m.persistence]"
               label "Cautious: [m.cautious]"
               label "Conviction: [m.conviction]"
               label "Trust in others: [m.trust]"
               label "Loyalty: [m.loyalty]"
               
screen connection_stat(): # Inherits background color of VN only. 
    frame:
        xalign 1.0
        vbox:
            text "Connection"

                
screen character_bios(): # Inherits background color of VN only.
    frame:
        xalign 1.0
        vbox:
          
            text "Character Bios"
WIP: Ring av Guder - (Contemporary Fantasy VN/Dating Sim?)

What do you get when you inherit a mystical ring, meet Norse Dieties, and Werewolves, Satyrs, or Dwarves? Possibilities.

General Completion: 5% - (Still working on story plot.)
Story status: 1% (In progress of revamping)
Scripting: 1% (Prologue is about done)
Character Art: 0% (Would like to find a Bara-type Artist, but will learn to draw them myself if necessary)
BG/CG's: 0% (None so far)

Post Reply

Who is online

Users browsing this forum: No registered users