[Solved] Use an Imagemap to set Pronouns?

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
Hojoo
Regular
Posts: 25
Joined: Wed Sep 28, 2022 7:26 pm
Contact:

[Solved] Use an Imagemap to set Pronouns?

#1 Post by Hojoo »

I've been trying to incorporate choosing player pronouns, but I'm getting stuck on trying to get it to work with hotspots in my character creator.

Below is part of a imagemap using buttons to select pronoun options, and trying to call the function to select pronouns:

Code: Select all

        hotspot( 66, 107, 16, 7) action SetVariable("pronoun", 0), Function(pronoun_selection(pronoun))
        hotspot( 83, 107, 13, 7) action SetVariable("pronoun", 1), Function(pronoun_selection(pronoun))
        hotspot( 97, 107, 10, 7) action SetVariable("pronoun", 2), Function(pronoun_selection(pronoun))
Below are the default variables and the pronoun_selection function, using NPCKC's Pronoun Tool for Ren'Py as a guide:

Code: Select all

default pronoun = 0
default pronounlist = [("they/them"),("she/her"),("he/him")]
default selectedpronouns = pronounlist[pronoun]
default theylist = [("they"),("she"),("he")]
default themlist = [("them"),("her"),("him")]
default theirlist = [("their"),("her"),("his")]
default theirslist = [("theirs"),("hers"),("his")]
default slist = [(""),("s"),("s")]
default eslist = [(""),("es"),("es")]
default arelist = [("are"),("is"),("is")]
default they = theylist[pronoun]
default them = themlist[pronoun]
default their = theirlist[pronoun]
default theirs = theirslist[pronoun]
default s = slist[pronoun]
default es = eslist[pronoun]
default are = arelist[pronoun]

init python:
    def pronoun_selection(pronoun):
        selectedpronouns = pronounlist[pronoun]
        they = theylist[pronoun]
        them = themlist[pronoun]
        their = theirlist[pronoun]
        theirs = theirslist[pronoun]
        s = slist[pronoun]
        es = eslist[pronoun]
        are = arelist[pronoun]
        return selectedpronouns
The error I get when clicking on the hotspots in-game is:
File "renpy/common/00action_other.rpy", line 578, in __call__
rv = self.callable(*self.args, **self.kwargs)
TypeError: 'str' object is not callable
Any help would be wonderful!
Last edited by Hojoo on Sun Aug 25, 2024 2:47 pm, edited 3 times in total.

laure44
Regular
Posts: 87
Joined: Mon Mar 08, 2021 10:55 pm
Projects: Arkan'sTower, Gemshine Lorelei!
Location: France
Contact:

Re: Using an Imagemap to set Pronouns?

#2 Post by laure44 »

Try:

Code: Select all

Function(pronoun_selection, pronoun)
instead of

Code: Select all

Function(pronoun_selection(pronoun))

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2476
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Using an Imagemap to set Pronouns?

#3 Post by Ocelot »

To provide some explanation to laure44 suggestiuon you can look at this post:
viewtopic.php?p=557062#p557062

Note that it will not completely solve th problem, since pronoun value will be evaluated when screen is shown. This means that pronoun_selection will be called with whatever value pronoun held when screen was shown. Provide value explicitely, like you did for SetVariable.
< < insert Rick Cook quote here > >

Hojoo
Regular
Posts: 25
Joined: Wed Sep 28, 2022 7:26 pm
Contact:

Re: Using an Imagemap to set Pronouns?

#4 Post by Hojoo »

Hi! Thank you both for the suggestions! I've run into 2 problems with what I have right now:
  1. Fixing it to be Function(pronoun_selection, pronoun) definitely fixed the error I was having, but right now, selecting pronouns in the character creator interacts with the displayables below the screen —i.e, it brings up the dialogue box under the character creator to the front, even though I have modal True at the screen start. Why is this happening?
  2. Ocelot wrote: Sat Dec 31, 2022 8:09 pm [...] pronoun value will be evaluated when screen is shown. This means that pronoun_selection will be called with whatever value pronoun held when screen was shown. Provide value explicitely, like you did for SetVariable.
    Thank you! You're right, it doesn't update. I tried to do something like:

    Code: Select all

            hotspot( 66, 107, 16, 7) action SetVariable("pronoun", 0), Function(pronoun_selection, 0)
            hotspot( 83, 107, 13, 7) action SetVariable("pronoun", 1), Function(pronoun_selection, 1)
            hotspot( 97, 107, 10, 7) action SetVariable("pronoun", 2), Function(pronoun_selection, 2)
    
    But that isn't it; how would I provide value explicitly?
Last edited by Hojoo on Fri Jan 13, 2023 6:50 pm, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2476
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Using an Imagemap to set Pronouns?

#5 Post by Ocelot »

1) modal has no relation to the screen order. Try to display imagemap with higher z-order.
2) Missed it. All something = something_else in pronoun_selection should be store.something = something_else
< < insert Rick Cook quote here > >

Hojoo
Regular
Posts: 25
Joined: Wed Sep 28, 2022 7:26 pm
Contact:

Re: Using an Imagemap to set Pronouns?

#6 Post by Hojoo »

  1. Adding zorder 100 stops the dialogue box from coming to the front, but I'm still getting the problem where displayables behind the screen are interactable, so dialogue progresses under the screen while clicking to select pronouns.
  2. Ocelot wrote: Tue Jan 10, 2023 2:42 pm [...] All something = something_else in pronoun_selection should be store.something = something_else
    Thank you! I didn't even think to use store; I set it up like this, and it seems to be working:

    Code: Select all

    init python:
        def pronoun_selection(pronoun):
            store.selectedpronouns = pronounlist[pronoun]
            store.they = theylist[pronoun]
            store.them = themlist[pronoun]
            store.their = theirlist[pronoun]
            store.theirs = theirslist[pronoun]
            store.s = slist[pronoun]
            store.es = eslist[pronoun]
            store.are = arelist[pronoun]
    
    So that's a massive step in the right direction.

Hojoo
Regular
Posts: 25
Joined: Wed Sep 28, 2022 7:26 pm
Contact:

Re: Using an Imagemap to set Pronouns?

#7 Post by Hojoo »

Okay besties, this is the code that works — updated with all the changes, plus some extra. The Function(pronoun_selection, pronoun) calls were redundant because they're already passing the pronoun variable, which already holds the index of the selected pronoun. It was causing problems and displaying not-the-actually-selected pronouns. So it works better just as Function(pronoun_selection).

Code: Select all

        hotspot( 66, 107, 16, 7) action SetVariable("pronoun", 0), Function(pronoun_selection)
        hotspot( 83, 107, 13, 7) action SetVariable("pronoun", 1), Function(pronoun_selection)
        hotspot( 97, 107, 10, 7) action SetVariable("pronoun", 2), Function(pronoun_selection)
Which means that the pronoun_selection function went from def pronoun_selection(pronoun) to def pronoun_selection() too.

Code: Select all

default pronoun = 0
default pronounlist = [("they/them"),("she/her"),("he/him")]
default selectedpronouns = pronounlist[pronoun]
default theylist = [("they"),("she"),("he")]
default themlist = [("them"),("her"),("him")]
default theirlist = [("their"),("her"),("his")]
default theirslist = [("theirs"),("hers"),("his")]
default slist = [(""),("s"),("s")] ## For verbs that conjugate with -s like "walk", e.g., she/he walks, they walk.
default eslist = [(""),("es"),("es")] ## For verbs that conjugate with -es like "go", e.g., she/he goes, they go.
default arelist = [("are"),("is"),("is")] ## For the verb "to be", e.g., she/he is, they are.
default they = theylist[pronoun]
default them = themlist[pronoun]
default their = theirlist[pronoun]
default theirs = theirslist[pronoun]
default s = slist[pronoun]
default es = eslist[pronoun]
default are = arelist[pronoun]

init python:
    def pronoun_selection():
        store.selectedpronouns = pronounlist[pronoun]
        store.they = theylist[pronoun]
        store.them = themlist[pronoun]
        store.their = theirlist[pronoun]
        store.theirs = theirslist[pronoun]
        store.s = slist[pronoun]
        store.es = eslist[pronoun]
        store.are = arelist[pronoun]
Thanks everyone!

User avatar
m_from_space
Eileen-Class Veteran
Posts: 1128
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Using an Imagemap to set Pronouns?

#8 Post by m_from_space »

Hojoo wrote: Tue Nov 28, 2023 4:25 pm

Code: Select all

default pronounlist = [("they/them"),("she/her"),("he/him")]
Is there a specific reason why you put all your list items inside brackets? They don't do anything. This is sufficient:

Code: Select all

default pronounlist = ["they/them", "she/her", "he/him"]
If you want to be able to translate those pronouns using Renpy's translation system, you should do this on the other hand:

Code: Select all

default pronounlist = [_("they/them"), _("she/her"), _("he/him")]

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot]