Don't know how to remove imagebuttons.

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
Paul Kinsella
Regular
Posts: 29
Joined: Sat May 02, 2020 9:53 am
Contact:

Don't know how to remove imagebuttons.

#1 Post by Paul Kinsella » Wed Apr 13, 2022 9:12 pm

I am a novice at renpy. I have the following code as shown below. But when one of the imagebuttons takes the player to "label chief:" all the imagebuttons from "label start:" stay. How do I tell imagebuttons to go away when I'm done with them. Better yet, is there a handy code that clears the screen of all images before a new page or "label" appears. As I'm a novice, who has spent days on this problem, an example of the solution code would be much appreciated. :D

# Big Game Example ##################################################
# Define and declare the color of each character. ##################
define c = Character("Chief",color="#CC0000")
define y = Character("You",color="#0066CC")
define d = Character("Doctor Deeth",color="#CC0000")
define s = Character("Officer Seen",color="#CC0000")
image office = "your_office_background.png"
# New place, room, or container. ####################################
label start:
scene your_office_background
show screen something
"Welcome!"
screen something:
# real buttons here on top...
imagebutton:
idle "your_conference_door_closed.png"
hover "your_conference_door_open.png"
xpos 75 ypos 77
action Jump('test')
imagebutton:
idle "your_chief_door_closed.png"
hover "your_chief_door_open.png"
xpos 325 ypos 75
action Jump('chief')
imagebutton:
idle "your_lounge_door_closed.png"
hover "your_lounge_door_open.png"
xpos 562 ypos 70
action Jump('test')
imagebutton:
idle "your_shooting_door_closed.png"
hover "your_shooting_door_open.png"
xpos 803 ypos 75
action Jump('test')
imagebutton:
idle "your_parking_door_closed.png"
hover "your_parking_door_open.png"
xpos 1040 ypos 73
action Jump('test')
imagebutton:
idle "your_phone.png"
hover "your_phone.png"
xpos 400 ypos 340
action Jump('test')
imagebutton:
idle "your_mug.png"
hover "your_mug.png"
xpos 535 ypos 353
action Jump('test')
imagebutton:
idle "your_todo.png"
hover "your_todo.png"
xpos 625 ypos 409
action Jump('test')
imagebutton:
idle "your_computer.png"
hover "your_computer.png"
xpos 715 ypos 280
action Jump('test')
imagebutton:
idle "your_trash.png"
hover "your_trash.png"
xpos 951 ypos 490
action Jump('test')
# drawers...
imagebutton:
idle "your_drawer_closed_left.png"
hover "your_drawer_open_left.png"
xpos 350 ypos 571
action Jump('test')
imagebutton:
idle "your_drawer_closed_left.png"
hover "your_drawer_open_left.png"
xpos 350 ypos 490
action Jump('test')
imagebutton:
idle "your_drawer_closed_right.png"
hover "your_drawer_open_right.png"
xpos 810 ypos 571
action Jump('test')
imagebutton:
idle "your_drawer_closed_right.png"
hover "your_drawer_open_right.png"
xpos 810 ypos 490
action Jump('test')
# New place, room, or container. ####################################
label test:
"Test text text text text text!"
# New place, room, or container. ####################################
label chief:
scene s1chiefsoffice
show s1chiefatdesk at truecenter
c "Welcome, Detective."
menu:
"It's good to be here. I welcome the opportunity to help the community.":
jump whatever
"It's good to be here. I am looking forard to to working my first case.":
jump whatever
# New place, room, or container. ####################################
label whatever:
y "Good to be here. I-"
c "Fine. Fine. Enough with the chit-chat. Let's get to work!"
c "Early this morning there was a stabbing in Stickville!"
c "We have the suspect in custody. He's covered with the victim's blood."
c "We also have two eye-witnesses and a solid motive."
c "what I need from you is..."
c "One: find the murder weapon."
c "And two: confirm that the cause of death was 'stabbing'."
c "Come back to my office as soon as you have compleaed both tasks."
y "Okay. Thank you."
jump yourdeskfirsttime
# Return ends the game. ###############################################
return

rayminator
Miko-Class Veteran
Posts: 754
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Don't know how to remove imagebuttons.

#2 Post by rayminator » Wed Apr 13, 2022 10:36 pm

I would put screen inside it's own rpy file and I would us call screen something instead of show

here is a example:

Code: Select all

screen something:
# real buttons here on top...
    imagebutton:
        idle "your_conference_door_closed.png"
        hover "your_conference_door_open.png"
        xpos 75 ypos 77
        action Jump('test'), Hide("something")
    imagebutton:
        idle "your_chief_door_closed.png"
        hover "your_chief_door_open.png"
        xpos 325 ypos 75
        action Jump('chief'), Hide("something")

User avatar
Paul Kinsella
Regular
Posts: 29
Joined: Sat May 02, 2020 9:53 am
Contact:

Re: Don't know how to remove imagebuttons.

#3 Post by Paul Kinsella » Sat Apr 16, 2022 5:11 pm

.

Thank you for getting back to me so quickly. I inserted your sample code (see the code below) but it did not seem to change anything. You wrote
I would put screen inside it's own rpy file and I would us call screen something instead of show
how do I put a screen in it's own renpy file? And how do I use call screen something?" Keep in mind that I'm a novice and an example of the code with changes made would be very much appreciated.

Code: Select all

screen something:
# real buttons here on top...
# testing ground 1 ##################################################

# Define and declare the color of each character. ##################
define c = Character("Chief",color="#CC0000")
define y = Character("You",color="#0066CC")
define d = Character("Doctor Deeth",color="#CC0000")
define s = Character("Officer Seen",color="#CC0000")

image office = "your_office_background.png"
# New place, room, or container. ####################################
label start:
    scene your_office_background
    show screen something
    "Welcome!"
screen something:
# real buttons here on top...
    imagebutton:
        idle "your_conference_door_closed.png"
        hover "your_conference_door_open.png"
        xpos 75 ypos 77
        action Jump('test'), Hide("something")
    imagebutton:
        idle "your_chief_door_closed.png"
        hover "your_chief_door_open.png"
        xpos 325 ypos 75
        action Jump('chief'), Hide("something")
    imagebutton:
        idle "your_lounge_door_closed.png"
        hover "your_lounge_door_open.png"
        xpos 562 ypos 70
        action Jump('test')
    imagebutton:
        idle "your_shooting_door_closed.png"
        hover "your_shooting_door_open.png"
        xpos 803 ypos 75
        action Jump('test')
    imagebutton:
        idle "your_parking_door_closed.png"
        hover "your_parking_door_open.png"
        xpos 1040 ypos 73
        action Jump('test')
    imagebutton:
        idle "your_phone.png"
        hover "your_phone.png"
        xpos 400 ypos 340
        action Jump('test')
    imagebutton:
        idle "your_mug.png"
        hover "your_mug.png"
        xpos 535 ypos 353
        action Jump('test')
    imagebutton:
        idle "your_todo.png"
        hover "your_todo.png"
        xpos 625 ypos 409
        action Jump('test')
    imagebutton:
        idle "your_computer.png"
        hover "your_computer.png"
        xpos 715 ypos 280
        action Jump('test')
    imagebutton:
        idle "your_trash.png"
        hover "your_trash.png"
        xpos 951 ypos 490
        action Jump('test')
        # drawers...
    imagebutton:
        idle "your_drawer_closed_left.png"
        hover "your_drawer_open_left.png"
        xpos 350 ypos 571
        action Jump('test')
    imagebutton:
        idle "your_drawer_closed_left.png"
        hover "your_drawer_open_left.png"
        xpos 350 ypos 490
        action Jump('test')
    imagebutton:
        idle "your_drawer_closed_right.png"
        hover "your_drawer_open_right.png"
        xpos 810 ypos 571
        action Jump('test')
    imagebutton:
        idle "your_drawer_closed_right.png"
        hover "your_drawer_open_right.png"
        xpos 810 ypos 490
        action Jump('test')
# New place, room, or container. ####################################
label test:
    "Test text text text text text!"
# New place, room, or container. ####################################
label chief:
    scene s1chiefsoffice
    show s1chiefatdesk at truecenter
    c "Welcome, Detective."
menu:
    "It's good to be here. I welcome the opportunity to help the community.":
        jump whatever
    "It's good to be here. I am looking forard to to working my first case.":
        jump whatever
# New place, room, or container. ####################################
label whatever:
    y "Good to be here. I-"
    c "Fine. Fine. Enough with the chit-chat. Let's get to work!"
    c "Early this morning there was a stabbing in Stickville!"
    c "We have the suspect in custody. He's covered with the victim's blood."
    c "We also have two eye-witnesses and a solid motive."
    c "what I need from you is..."
    c "One: find the murder weapon."
    c "And two: confirm that the cause of death was 'stabbing'."
    c "Come back to my office as soon as you have compleaed both tasks."
    y "Okay. Thank you."
    jump yourdeskfirsttime
# Return ends the game. ###############################################
    return

        
[/quote]

rayminator
Miko-Class Veteran
Posts: 754
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Don't know how to remove imagebuttons.

#4 Post by rayminator » Sat Apr 16, 2022 5:26 pm

do I really have tell you how to make a new file?

in atom click on file then select New File and make sure you put .rpy like something.rpy
same thing in most of other editors

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

Re: Don't know how to remove imagebuttons.

#5 Post by Imperf3kt » Sat Apr 16, 2022 10:30 pm

To put the screen in its own file simply means create a new file called "anything you like.rpy"
Putting your screen in there will merely make it easier to edit and modify, but is entirely optional.

To call a screen, in your script you would use

Code: Select all

call screen myScreen
myScreen of course being the screen name.

Whether a call is what you need to use or not depends on what you are trying to achieve. Do you want players to click on a button before anything happens, or can they click on them at will and the story progresses like normal (allowing the player to ignore the buttons altogether if they should so wish)
From what I can see of your code, it looks like you want players to be able to open and close drawers, look at their phone, etc, so in this case you could use either show scree myScreen or call screen myScreen. The project you've chosen looks ambitious for a beginner.


To help you get a better idea of how to structure your game, I strongly suggest reading through the documentation and using it as a reference.
https://www.renpy.org/doc/html/screen_actions.html
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

Post Reply

Who is online

Users browsing this forum: Bing [Bot], _ticlock_