Ren'Py Avoid seen image and show already talked to her.

Honey hunters

Member
Jan 23, 2020
118
26
Hi I'm new to Ren'Py coding , I'm making clickable images in my game , and coming to point in my game a lady character is present in her room Player clicked her MC make conversation with her and MC went back to hallway unfortunately player clicked her again " Here I want to show you already talked to her " but I don't know how to make this code in renpy. Can anyone help me for making this code.
 

NicoleWorks

Newbie
Jun 11, 2020
16
10
Since you can use Python in Ren'Py, you can basically have a variable has_talked_to_character, which you set to False initially, and to True after the first exchange. For example:

# Somewhere in the initialization
# use "$" to execute the line in Python
$ has_talked_to_character = False

# Character exchange
if has_talked_to_character:
"You already talked to her."​
else:
player "Hi!"​
character "Hi!"​
# after dialog with character​
$ has_talked_to_character = True​
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,964
16,211
# Somewhere in the initialization
# use "$" to execute the line in Python
$ has_talked_to_character = False
It isn't how you initialize a variable in Ren'py. There's a default and a define statement specifically designed for this, in order to avoid incompatibility with older save files.

So it should be default has_talked_to_character = False, that you put at 0 level of indentation anywhere in your code ; but obviously outside of an init or label block.
 
Last edited:

jon95

Member
Game Developer
Sep 29, 2018
176
393
i don't know if this can help you:
Python:
default talke1 = False

screen Girl1():
    modal True
    imagebutton idle "girl1.png" hover (im.MatrixColor("girl1.png", im.matrix.brightness(0.25))) focus_mask True action Jump("Girl1Talk")


label Girl1Talk:

    if not talke1:
        jump TalkGirl1

    else:
        "I already talked to her"
        jump map

        

label TalkGirl1:
    #write what you want
    $talke1=True
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
[...] MC make conversation with her and MC went back to hallway unfortunately player clicked her again " Here I want to show you already talked to her " but I don't know how to make this code in renpy.
I assume you're using something like imagemap (clickable rectangles) or imagebutton (clickable hotspots of any shape).

Personally, I prefer imagebutton and wrote up a while ago how to create clickable hotspots that way.
https://f95zone.to/threads/finding-...-point-click-game-on-renpy.25325/post-1565577
I also wrote a working tech-demo style game semi-recently, with actual code and images.
https://f95zone.to/threads/help-with-imagemaps.50306/post-3336719

Hopefully, whilst you're still new to RenPy - you won't need those explanations... but I'll link them anyway, just in case.

Meanwhile, there is another option to consider instead of "I already talked to her"...
You could just remove the clickable hotspot, so the player CAN'T pick the same conversation twice.

I'm thinking something like:

Python:
default went_to_house2 = False

screen imagebutton_example1_screen():
    modal True

    add "ib_eg1_background"

    imagebutton auto "ib_eg1_opt1_%s.png":
        focus_mask True
        action Jump ("day1_picked_house1")

    if went_to_house2 == False:
        imagebutton auto "ib_eg1_opt2_%s.png":
            focus_mask True
            action Jump ("day1_picked_house2")

    imagebutton auto "ib_eg1_opt3_%s.png":
        focus_mask True
        action Jump ("endof_myexample")


label start:

    scene black with fade
    "Start:.... "


label day1_start:

    scene black
    call screen imagebutton_example1_screen
    # no need to do anything here, since control will never reach here due to all the hotpots jumping to other places within the code.


label day1_picked_house1:

    scene black
    pc "I went to house 1."
    jump day1_start


label day1_picked_house2:

    scene black
    pc "I went to house 2."
  
    $ went_to_house2 = True
    jump day1_start


label endof_myexample:

    "*** THE END ***"

    return
In this fictitious example, the player can pick from 3 options. The first two are "go to house 1" and "go to house 2" and the third is "quit/exit".

For some arbitrary reason, you can only visit house 2 once. So rather that go with the "You already visited this house", I'm instead adding if went_to_house2 == False: to the screen code - to only show the clickable hotspot if the house hasn't been visited yet (well, the variable hasn't been set to True yet).

Alternatively, you could go with a standard screen outline and instead go with the example others have given, that would include code that looked something like:

Python:
label day1_picked_house2:

    scene black
    if went_to_house2 == False:
        pc "I went to house 2."
        $ went_to_house2 = True
    else:
        "You already visited this house."

    jump day1_start

Another solution to a completely different question, is if you were using menu: choices instead of clickable image hotspots. There you can make the menu choice optional by adding if statements after the menu option. Including something like:

Python:
label day1_start:
  
    menu:
        "Go to House 1" if went_to_house1 == False
            $ went_to_house1 = True
            jump day1_picked_house1

        "Go to House 2" if went_to_house2 == False
            $ went_to_house2 = True
            jump day1_picked_house2

        "I've visited all the houses, time to move on..."
        jump endof_myexample

label day1_picked_house1:

    #blah blah, more code...

In this case, menu choices will only appear once and again you won't need to include any "You already visited this house." type messages.
If you end up setting all the variables so that NO choices would appear... RenPy skips the menu all together and just continues on to the next statement.

There are all sort of variations on this menu: theme, where a final option of something like "Continue" is only shown if all the other options have already been picked... or the game keeps a count of how many menu options have been chosen with a simple number variable, and a "Continue" type menu option is shown after 1 or 2 or 3 or whatever many choices have been made (a handy way to make the player pick at least 1 option, without needing to pick all of them).

Anyway, that is a lot more than you asked for... but each has their own advantages/disadvantages and will be very situational depending on what you are trying to do in your game.