Create changeable icon beside character nametag?

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
lindsay-jb
Regular
Posts: 61
Joined: Tue Aug 25, 2020 1:05 am
Contact:

Create changeable icon beside character nametag?

#1 Post by lindsay-jb » Wed Feb 23, 2022 7:44 pm

Hello! I want to display an icon beside certain characters' names that basically displays their individual character "nerve" score. That score will determine how different events play out in the future. I looked up some different tutorials and tried this code, but it didn't work:

Code: Select all

if who is not None:
    if who == 'AMALIA' and amalia_nerve < 21:
        add "images/Nerve Icons/haunted.png"
    elif who == 'AMALIA' and amalia_nerve > 20 and amalia_nerve < 41:
        add "images/Nerve Icons/rattled.png"
    elif who == 'AMALIA' and amalia_nerve > 40 and amalia_nerve < 61:
        add "images/Nerve Icons/on edge.png"
    elif who == 'AMALIA' and amalia_nerve > 60 and amalia_nerve < 81:
        add "images/Nerve Icons/coping.png"
    elif who == 'AMALIA' and amalia_nerve > 80 and amalia_nerve <= 100:
        add "imagse/Nerve Icons/tough as nails.png"
But hopefully you can get what I'm trying to do? I want to display the icon beside the character's name and I want different icons to appear depending on the character nerve score. Anyone have suggestions on how to do this?

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Create changeable icon beside character nametag?

#2 Post by Per K Grok » Thu Feb 24, 2022 6:13 am

lindsay-jb wrote:
Wed Feb 23, 2022 7:44 pm
Hello! I want to display an icon beside certain characters' names that basically displays their individual character "nerve" score. That score will determine how different events play out in the future. I looked up some different tutorials and tried this code, but it didn't work:

Code: Select all

if who is not None:
    if who == 'AMALIA' and amalia_nerve < 21:
        add "images/Nerve Icons/haunted.png"
    elif who == 'AMALIA' and amalia_nerve > 20 and amalia_nerve < 41:
        add "images/Nerve Icons/rattled.png"
    elif who == 'AMALIA' and amalia_nerve > 40 and amalia_nerve < 61:
        add "images/Nerve Icons/on edge.png"
    elif who == 'AMALIA' and amalia_nerve > 60 and amalia_nerve < 81:
        add "images/Nerve Icons/coping.png"
    elif who == 'AMALIA' and amalia_nerve > 80 and amalia_nerve <= 100:
        add "imagse/Nerve Icons/tough as nails.png"
But hopefully you can get what I'm trying to do? I want to display the icon beside the character's name and I want different icons to appear depending on the character nerve score. Anyone have suggestions on how to do this?
One way could be to make the icon as a separate screen. Something like this. Just to illustrate the general idea. You should change the code to fit what you need.

Code: Select all

screen nerve(x):
    if x==1:
        add "reddot" pos (100, 390)
    elif x==2:
        add "bluedot" pos (100, 390)
    if x==3:
        add "greendot" pos (100, 390)


label start:


    scene bak_grund1

    show screen nerve(1)
    e "Hello world!"

    show screen nerve(2)
    e "You've created a new Ren'Py game."

    show screen nerve(1)
    e "Once you add a story, pictures, and music, you can release it to the world!"
    hide screen nerve   # you need to hide the screen when the icon is not shown

    e "Hello world!"


Post Reply

Who is online

Users browsing this forum: enaielei, Google [Bot]