Error 'variable is not defined' when I think it is?

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
zeroTheHero
Regular
Posts: 64
Joined: Mon May 07, 2018 10:49 am
Contact:

Error 'variable is not defined' when I think it is?

#1 Post by zeroTheHero »

I've been following the code from this topi viewtopic.php?f=51&t=50153 and made a messenger like screen similar to it:

Code: Select all

#Script.rpy
label start:
    show screen s_name
    $Bak="cafe (1).jpg"
    $m_msg = []
    $ msg_name = "sDextra"
    pause
    python:
        msg( "Pikachu",  who=True )
        msg("Charmander")
    return

#Screen code  
    
init python:
    style.txt_base = Style(style.default)
    def msg( personName, who=False, Tbox = False):
        store.m_msg.append((who, personName, Tbox))
        renpy.restart_interaction()
        renpy.pause()

screen s_name:
    frame background Bak:
        frame background None :   
            viewport:
                mousewheel True
                vbox spacing 15:
                    for message in m_msg:
                        $who, personName = message

                        $ xgn = 0.0 if who else 6.0
                        button xalign xgn xmaximum 580 xpadding 20 ypadding 10:
                            text "%s"%(personName)    
                            frame background "%s"%(Tbox):  
The error I get is "Tbox is not defined". If I try to write $ Tbox = 'False' or 'None' I get "Image False not found". Thing is, 'who', personName and Tbox are defined in the same way, and only Tbox gives this error. How do I get this working?

What I want to do: If you check out the thread I've posted, it has a pic of what my screen should (somewhat) look like. I'm trying to add a name above every text message. So, in the code above, 'Pikachu' is the name, and in the textbox I'm trying to create I'll add text later.

zeroTheHero
Regular
Posts: 64
Joined: Mon May 07, 2018 10:49 am
Contact:

Re: Error 'variable is not defined' when I think it is?

#2 Post by zeroTheHero »

Edit: I changed the last line to

Code: Select all

                    frame:
                        for Tbox in m_msg:
                            $who, personName, Tbox = Tbox
                            frame:
                                background "%s"%(Tbox) 
and have mixed success. Now, there's a black frame before the text Pikachu appears on screen, and the Tbox below Pikachu is huuuge. Will try to use frame properties. Also the next line, Charmander, is missing, I can't see it on screen (the Tbox mighta covered it up). Solving a problem = another problem... Well at least something's working

Post Reply

Who is online

Users browsing this forum: No registered users