[SOLVED] Imagebuttons not displaying, jumping straight to next 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
Jg119
Newbie
Posts: 2
Joined: Tue Jan 09, 2018 7:29 am
Contact:

[SOLVED] Imagebuttons not displaying, jumping straight to next label.

#1 Post by Jg119 » Tue Jan 09, 2018 7:52 am

Hi, I'm new to the forum, and new to renpy, and coding in general. I'm working on my first game, is a visual novel but i wanted to add sections in which the player is in room or a place and is tasked with finding objects in order to discover bits of the plot and also to set up flags for future interactions with characters.

Now for this sections of point-and-click gameplay; after a bunch of research i decided that the best way to implement them would be with imagebuttons, as i want every item that can be picked up to be "light up" when the player hovers the mouse over it, in order for them to know that is an interactive item. Imagemaps i believe, don't allow me to set up a "lighting up" of diferent hotspots as the player hovers the mouse over them but rader will change the image as the player hovers over each hotspot.

Anyway, I tried to implement imagebuttons on to the script by using a screen with a back ground and then adding over it the items that should be found but when the moment for the game to display this screen comes, it just skips it and goes straight into the next label which was supposed to be a label that went back on the screen so as to keep the player there until they were satisfied with looking around. I think it all boils down to the fact that I haven't gotten the hang of imagebuttons and screens. But i have tried looking around and there is not much documentation about doing this kind of screens with imagebuttons for ingame porpuses, so please if anyone can tell me where I went wrong and how I should go about doing this I would be grateful.

Code: Select all

	
	window show
        
        narrator "Hover your mouse over the scene to find objects that might hold clues or that might be of interest to you... Make sure to alway be thorough!"
        
        nvl clear
        window hide
        
    show screen hroom1
        
    $ renpy.pause (1.0, hard = True)
        
    screen hroom1:
            
        modal True

        add "images/room_1_idle.jpg"
    
        imagebutton idle "images/book_idle.png" hover "images/room_1_hover_book.png" xpos 210 ypos 526 focus_mask True action Jump("ntbk")
        imagebutton idle "images/exit_arrow.png" hover "images/exit_arrow_hover.png" xpos 980 ypos 520 focus_mask True action Jump("back1")
        
        $ renpy.pause (1.0, hard = True)
        
    label ntbk:
        
        hide screen hroom1
    
        jn"You have found a notebook with a pen. In the first page the word 'WRITE' stands out."
    
        show screen hroom1
            
        label back1:
            
            hide screen hroom1
        
            jn "Well, I guess I'll head back and search the other parts of the house, there might be more to see."
    
            jump inspecthouse
Last edited by Jg119 on Tue Jan 09, 2018 4:42 pm, edited 1 time in total.

User avatar
mitoky
Regular
Posts: 196
Joined: Sat Feb 07, 2015 9:12 pm
Projects: The Purring Demon's Love, CrossDol
Tumblr: mitokysvnstudio
Deviantart: mitoky
Contact:

Re: Imagebuttons not displaying, jumping straight to next label.

#2 Post by mitoky » Tue Jan 09, 2018 9:19 am

Try using "call screen" instead of "show screen".
Image

[Logo Commissions - OPEN] || Wish to support or tip me? Buy Me a Coffee!

User avatar
Remix
Veteran
Posts: 474
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet
Projects: An un-named 3d anime based trainer game
Contact:

Re: Imagebuttons not displaying, jumping straight to next label.

#3 Post by Remix » Tue Jan 09, 2018 12:09 pm

The modal True (in most cases) would be sufficient except you are basically just doing show screen, no interaction (dialogue etc), hide screen which does as you want, it shows it and instantly hides it.
Inverting the :
jn "Well, I guess I'll head back and search the other parts of the house, there might be more to see."
hide screen hroom1
might be enough

User avatar
Remix
Veteran
Posts: 474
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet
Projects: An un-named 3d anime based trainer game
Contact:

Re: Imagebuttons not displaying, jumping straight to next label.

#4 Post by Remix » Tue Jan 09, 2018 12:15 pm

Addendum to last...

Adding 'return' (without quotes) into the labels would be best... Ren'py will just continue to the next label if it does not read return...

Code: Select all

label a:
    "start"
label b:
    "... continued"
    return # ends the game.. goes to main menu or returns to the last known context
label c:
    "end" # we only get here if jumped

Jg119
Newbie
Posts: 2
Joined: Tue Jan 09, 2018 7:29 am
Contact:

Re: Imagebuttons not displaying, jumping straight to next label.

#5 Post by Jg119 » Tue Jan 09, 2018 4:39 pm

Thanks I managed to make it work using both the call screen method for the use of the screen and the return command at the end of the label that calls the screen so it that it doesn't default to the next label without clicking on the exit button for the screen. I don't know if it's efficient but it is working as i intended. Again thanks a lot!

Post Reply

Who is online

Users browsing this forum: Baidu [Spider], lking22, trooper6