I can't make items (imagebutton) stay in just one label

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
starlingmaximilian
Newbie
Posts: 15
Joined: Mon Oct 14, 2019 4:07 pm
Contact:

I can't make items (imagebutton) stay in just one label

#1 Post by starlingmaximilian »

I created a room in which I can navigate using arrows (using call screen).
Then, in the room I created a label called "kitchen" and in there an item (with a screen and imagebutton) called "dish". I wan't the "dish" to appear only in the kitchen and for that I use show screen because if I use call screen again it conflicts with the call screen I'm using for the navigation arrows. When I start the game, I can use the navigation arrows completely fine, and sure enough, when I enter the kitchen the "dish" actually appears! The problem is that when I leave the kitchen the dish doesn't leave the screen.
I would like to know if you guys have a nice solution for this issue. I thought about adding the item as part of the navigation screen, but I don't think that's a smart solution... rather it would be like a "patch", and I wan't to do things right. I also thought about using some sort of variable using python code... Like some variable that is just active while the label kitchen is "active" but I don't have a clue of how to do that!
Here's the relevant (I think) part of the code.
screen movement(leftLocation, rightLocation):
frame:
xalign 0.0 ypos 400
imagebutton:
idle "arrowPasiveLeft.png"
action Jump(leftLocation)
frame:
xalign 1.0 ypos 400
imagebutton:
idle "arrowPasiveRight.png"
action Jump(rightLocation)
.
.
.
screen dish():
frame:
xalign 0.8 yalign 0.8
imagebutton:
idle "dish.png"
action Jump("start")
.
.
.
label kitchen:
scene kitchen
show screen dish
call screen movement("exit","living")
Sorry for the long explanation, and I hope you guys can help me (again).

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: I can't make items (imagebutton) stay in just one label

#2 Post by Imperf3kt »

Instead of using Call screen you should use Show screen.
Call is for when you want to go somewhere and then return to where you came from.
I assume your navigation isn't intended to take you back to the starting location every time you go to a new area.

The actual issue, however, is because you never hide the dish screen.
Why not place the dish image into the kitchen screen (you can have multiple things in one screen) and edit how your navigation works do that when you go to a new screen, you also hide the previous one.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

starlingmaximilian
Newbie
Posts: 15
Joined: Mon Oct 14, 2019 4:07 pm
Contact:

Re: I can't make items (imagebutton) stay in just one label

#3 Post by starlingmaximilian »

Hi! Thank you for replying.
I can't use show screen because I want the screen to disappear when there's dialogue (a question of style). So I use call screen so it shows only when called... Also I don't want to have to hide the navigation window all the time.
Why not place the dish image into the kitchen screen (you can have multiple things in one screen) and edit how your navigation works do that when you go to a new screen, you also hide the previous one.
Kitchen is not a screen, it's a label. The screen is "dish" and yes, I want to hide it as I said here.
I also thought about using some sort of variable using python code... Like some variable that is just active while the label kitchen is "active" but I don't have a clue of how to do that!
So it all boils down to this. I want to find a way to show the "dish screen" just in the kitchen label. I know "in concept" what I want to do, but I don't know how to do it, here's a mock code to explain it better.

Code: Select all

while label kitchen = True:
     show screen dish
else:
     hide screen dish
Obviously this code doesn't work, but this is what I want to do... Any ideas?

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: I can't make items (imagebutton) stay in just one label

#4 Post by Imperf3kt »

This is how I would do it.

Code: Select all

label kitchen:
    show screen dish
    "There's a dish here." 
    hide screen dish
    "There's no dish here." 
    return

Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

starlingmaximilian
Newbie
Posts: 15
Joined: Mon Oct 14, 2019 4:07 pm
Contact:

Re: I can't make items (imagebutton) stay in just one label

#5 Post by starlingmaximilian »

That wouldn't work. The navigation HUD (call screen) would come and the dish screen would be hidden already (I already tried this) without letting the user interact with it.
I suppose I need to attach a variable to the kitchen label somehow.
Or maybe some command that hides the screen from hiding unless the user performs ANY action?
Maybe there's another way of adding items to my game that doesn't imply using screens?

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: I can't make items (imagebutton) stay in just one label

#6 Post by Imperf3kt »

It may help if we could see more of how your navigation works and what you use the kitchen label for.

The code I posted, if used with a call should take you to the kitchen label, show the dish screen, display lines of dialogue then remove the dish screen and return you to where you came from.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: I can't make items (imagebutton) stay in just one label

#7 Post by philat »

There are several point and click examples on the forums that would accomplish what you want. In general, I would say familiarize yourself with the use statement.

starlingmaximilian
Newbie
Posts: 15
Joined: Mon Oct 14, 2019 4:07 pm
Contact:

Re: I can't make items (imagebutton) stay in just one label

#8 Post by starlingmaximilian »

It may help if we could see more of how your navigation works and what you use the kitchen label for.
Hi. This is the whole code.

Code: Select all

define y = ("Yukio")

screen movement(leftLocation, rightLocation):
        frame:
            xalign 0.0 ypos 400
            imagebutton:
                idle "arrowPasiveLeft.png"
                action Jump(leftLocation)
        frame:
            xalign 1.0 ypos 400
            imagebutton:
                idle "arrowPasiveRight.png"
                action Jump(rightLocation)

label start:
scene bathroom
default firstBat = 0
if firstBat == 0:
    y "Where am I?"
    y "What happened?"
    $ firstBat += 1
call screen movement("living","exit")

label living:
scene living
default firstLiv = 0
if firstLiv == 0:
    y "It is night already..."
    $ firstLiv += 1
call screen movement("kitchen","start")

label exit:
scene exit
default firstExi = 0
if firstExi == 0:
    y "I need to find a way to open this door"
    $ firstExi += 1
call screen movement("start","kitchen")

screen dish():
    frame:
        xalign 0.8 yalign 0.8
        imagebutton:
            idle "dish.png"
            action Jump("start")

label kitchen:
scene kitchen
show screen dish
default firstKit = 0
if firstKit == 0:
    y "This is a mess"
    y "The food rests on the plates are recent"
    $ firstKit += 1
call screen movement("exit","living")

When you run it, this is what you get.



Obviously, I want the "dish" (yeah, that square thing) to disappear! It works as intended when you click on it though (action jump label bathroom).
The code I posted, if used with a call should take you to the kitchen label, show the dish screen, display lines of dialogue then remove the dish screen and return you to where you came from.
If I do what you told me to, since I'm calling the dish, the navigation HUD (also using call screen) won't show (because, as you know, the game just waits for user input before doing anything else, thus the Navigation HUD won't appear). If instead I use show screen and hide screen, then the dish will hide right after the dialogue without giving the player the chance to interact with it.

There are several point and click examples on the forums that would accomplish what you want. In general, I would say familiarize yourself with the use statement.
I don't know what the use statement is, but I'm going to start looking into it right now, I'll browse the forum, but if you can think of a particularly good post, please let me know.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]