screen troubles

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
Omni
Newbie
Posts: 5
Joined: Fri Oct 02, 2015 8:36 pm
Contact:

screen troubles

#1 Post by Omni »

I have been having difficulty using the screen function in Ren'Py, the background element in particular.

I'm trying to have a screen with buttons on it, but I don't want to use an image map as I want the buttons to only appear if the right conditions are met.

I have a couple if images defined at the start, but not in an init block and before the start label

Code: Select all

image bg yourRoom = "bedroom.jpg"
image bg yourComp = "computer.jpg"
In a different file, I have this screen defined.

Code: Select all

screen yourRoom():
    window:
        pos(0,0)
        anchor ('top','left')
        xysize(1024,768)
        xpadding 0
        ypadding 0
        background None
        # background Frame("bedroom.jpg")
        vbox:
            button:
                pos(600,350)
                text "computer"
                background None
                #action useYourComputer
and in a different file again if this set up.

Code: Select all

label useYourComputer:
    scene bg yourComp
    you "This is my computer"
in the original script file, after the start label, I have this:

Code: Select all

you "Ah! A brand new day. I wonder what crazy shenanigans I'll get up to this time."
    
    show screen yourRoom
    
    you "This is my room"

As it is right now, the screen yourRoom just makes the word "computer" appear in the middle of the screen.

If I uncomment the buttons action, I get the error: name 'useYourComputer' is not defined

It's not a problem with the labels visibility as it works fine if I jump to it from the script file.
It's not an execution order problem either as if I put the screens in an init block, it still happens.


Also, how do use the background element for anything other than making it invisible?
if I use: background Frame("bedroom.jpg")
in the screen yourRoom
I get the error:
error in script
you "This is my room"
TypeError: unsupported opperand type(s) for +: 'NoneType' and 'NoneType'

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: screen troubles

#2 Post by trooper6 »

There are things I don't really understand about what you are trying to do...so I will help as far as I can...then I will ask question.

Here is your screen:

Code: Select all

screen yourRoom():
    window:
        pos(0,0)
        anchor ('top','left')
        xysize(1024,768)
        xpadding 0
        ypadding 0
        background "images/apartment.jpg"
        vbox:
            textbutton "computer":
                pos(600,350)
                #background None #We need to talk about this
                action NullAction() #We need to talk about this
This will give your screen the background of an image.
I turned your button into a text button, it just seemed easier.
Question 1) Why did you give your button a background of none? Your player may not realize that the text is a button without a background
Comment on your action. You had action useYourComputer in your code. But useYourComputer is not an action. All actions available to you are on this page:
http://www.renpy.org/doc/html/screen_actions.html

If you want to jump to the label useYourComputer...you would
action Jump("useYourComputer")

But this code is not going to do what you want it to in the end:

Code: Select all

screen yourRoom():
    window:
        pos(0,0)
        anchor ('top','left')
        xysize(1024,768)
        xpadding 0
        ypadding 0
        background "images/apartment.jpg"
        vbox:
            textbutton "computer":
                pos(600,350)
                #background None
                action Jump("useYourComputer")

label start:
    "You" "Ah! A brand new day. I wonder what crazy shenanigans I'll get up to this time."
    show screen yourRoom()
    "You" "This is my room."

    return
    
label useYourComputer:
    scene bg underpassd
    "You" "This is my computer"
    return
Why is this not going to work? Because when you press your button and jump to that label, you won't see the background because it'll be behind the yourRoom() screen.

So you could call the screen yourRoom() which will make it disappear after you make a choice.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Omni
Newbie
Posts: 5
Joined: Fri Oct 02, 2015 8:36 pm
Contact:

Re: screen troubles

#3 Post by Omni »

Thank you for the assistance.

The reason why I gave the button a background of none was because I was trying to keep it simple as I trial and errored may way to figuring out how it all worked. Ultimately I plan on having an image for the button with some text on top of it. Would I be able to have an image on a text button?

With the action I tried: action jump useYourComputer
I see that I was on the right track, but I just didn't know the right syntax.

With the background element, is there a way to use an image variable for that instead of directly referring to a specific image?
I could probably get by with directly referring to images, but I would like to know for potential future reference.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Jackkel Dragon