• To improve security, we will soon start forcing password resets for any account that uses a weak password on the next login. If you have a weak password or a defunct email, please update it now to prevent future disruption.

Ren'Py Need a coder to help with a simple task

Erros

Member
Aug 28, 2017
291
337
Hi,

I'm in dire need of a python coder who's good with ren'py.
I'm creating a game and there is a feature that i want to add, but i didn't manage to make it work like i wanted.

Basically what i want to do is hide an imagebutton somewhere in my scene and when you click and this image it unlocks a special image in the gallery.

I have already have a working gallery, but the code that i made for the imagebutton doesn't work/appear in the game and i don't have errors that can point out where is the mistake i have made.

So if you know how to code something like that, i would be glad to receive your help.
If you can do it just for one image, i should be able to reproduce it later by myself.

I'll be really thankfull to you.
 

xort

Active Member
Jun 1, 2017
598
1,418
Could you just use an image that was only transparency, then you just have a normal screen click button image right?
 

Erros

Member
Aug 28, 2017
291
337
After a good night of sleep, i had an idea that i tested and it's a success. I should be able to do it alone (maybe), but i'll have to rewrite most of my code to make it work correctly.
 

memes2501

Newbie
Mar 4, 2018
25
14
Could you just use an image that was only transparency, then you just have a normal screen click button image right?
Essentially, this is how I see most games do it. Load the background picture, then the foreground picture you want with the secret clickable object.

Another thing I can think of, would be to have a list of coordinates [Top Left, Top Right, Bottom Left, Bottom Right] and associate it to a specific screen. It's basically a square that you would draw on the appropriate screen. This would be used if you didn't want to highlight the special object (otherwise it might look odd). There are quite a few ways of doing it. Hopefully the way you thought of works well!
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,219
14,975
and the are all you need to do this.

Code:
screen myScreen:
    imagemap:
         # The base picture
         idle "myBackground.png"
         # The base picture with all hotspots marked. 
         # Ren'py will display just what's needed
         hover "myBackground_hover.png"

         hotspot ( [u]x[/u], [u]y[/u], [u]width[/u], [u]height[/u] ) action Function( g.unlock, "gal01" )
assuming that g is your Gallery object and "gal01" the ID of the unlocked picture.
 

Erros

Member
Aug 28, 2017
291
337
Hi, thank you i'll look at that.
And I have to admit that I have the bad habit of not reading tutorials, i should probably start reading tutorials :test:

and for the code here is what i made

Code:
screen actual scene.png:
#Click to pass to the next scene
    imagebutton:
        xpos 0
        ypos 0
        focus_mask True
        idle "actual scene"
        hover "actual scene"
        action Jump("next scene")

    if not "image in gallery" in gallery:
        imagebutton:
#to choose where i want to put the image
            xpos 0.2
            ypos 0.1
            focus_mask True
            idle "image hidden"
            hover "image hidden hover"
            action [addimage("image in gallery"), Jump("next scene")]
I manage to make it work with this code.
I'll try what you showed me and see if i can make it work.