[SOLVED] Need help with side images and imagebuttons

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
IsaacChambers
Newbie
Posts: 4
Joined: Sun May 22, 2022 1:04 pm
itch: Isaacchambers
Contact:

[SOLVED] Need help with side images and imagebuttons

#1 Post by IsaacChambers »

Hey guys,

I'm pretty new to Ren'Py and I've been having issues with getting my side images to show up.
In my game the player starts with a choice of a "male" or "female" character in the form of two imagebuttons, followed by a "choose your name".
After that the chosen side image should show up whenever the main character speaks, but even after all the YT tutorials and browsing the LSForum I can't seem to make it work.

this is the code for the imagebuttons (which works perfectly, I just have to link them to an actual choice now)

Code: Select all

        call screen char_choice

        screen char_choice():
            add "bg black"
            modal True

            imagebutton auto "bg_male_%s":
                focus_mask True
                hovered SetVariable("screen_tooltip", "male")
                unhovered SetVariable("screen_tooltip", "")
                action Jump ("choose_male")

            imagebutton auto "bg_female_%s":
                focus_mask True
                hovered SetVariable("screen_tooltip", "female")
                unhovered SetVariable("screen_tooltip", "")
                action Jump ("choose_female")


label choose_male:
    jump begin

label choose_female:
    jump begin


label begin:
And this is the code I have for the side image so far (the file I'm using for now is called "side_male_normal.png")

Code: Select all

        define player = Character("player", image="side_male_normal.png", xalign=0, yalign=1.0)

        image side player normal = ("side_male_normal.png")

        init python:
            config.side_image_tag = "player"

        $ player = renpy.input("What is your name?", default="Traveler", length=15)
        
        player normal "So this is what it's come to now?"
Whenever I run it, I get the following error message:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 47, in script
    player normal "So this is what it's come to now?"
  File "renpy/common/00library.rpy", line 268, in say
    who(what, interact=interact, *args, **kwargs)
Exception: Say has image attributes (u'normal',), but there's no image tag associated with the speaking character.

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 47, in script
    player normal "So this is what it's come to now?"
  File "renpy/ast.py", line 721, in execute
    renpy.exports.say(who, what, *args, **kwargs)
  File "renpy/exports.py", line 1417, in say
    renpy.store.say(who, what, *args, **kwargs)
  File "renpy/common/00library.rpy", line 268, in say
    who(what, interact=interact, *args, **kwargs)
  File "renpy/character.py", line 1189, in __call__
    old_attr_state = self.handle_say_attributes(False, interact)
  File "renpy/character.py", line 1001, in handle_say_attributes
    if self.resolve_say_attributes(predicting, attrs):
  File "renpy/character.py", line 927, in resolve_say_attributes
    raise Exception("Say has image attributes %r, but there's no image tag associated with the speaking character." % (attrs,))
Exception: Say has image attributes (u'normal',), but there's no image tag associated with the speaking character.

Windows-10-10.0.19041
Ren'Py 7.4.11.2266
Testing Site 1.0
Sun May 22 14:59:16 2022
I'm sure I'm just missing something really obvious, but any help would be really appreciated!
Last edited by IsaacChambers on Sat May 28, 2022 1:49 am, edited 1 time in total.

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Need help with side images and imagebuttons

#2 Post by rayminator »

change

Code: Select all

define player = Character("player", image="side_male_normal.png", xalign=0, yalign=1.0)
to

Code: Select all

define player = Character("player", image="player", xalign=0, yalign=1.0)
and put a full location it best to do so

Code: Select all

image side player normal = ("side_male_normal.png")
like so

Code: Select all

image side player normal = ("images/side_images/side_male_normal.png")
remove this it's not need when renpy have it's own in screens.rpy

Code: Select all

init python:
            config.side_image_tag = "player"
this is renpy side image

Code: Select all

if not renpy.variant("small"):
        add SideImage() xalign 0.0 yalign 1.0
more info on side images
https://www.renpy.org/doc/html/side_ima ... ide-images

IsaacChambers
Newbie
Posts: 4
Joined: Sun May 22, 2022 1:04 pm
itch: Isaacchambers
Contact:

Re: Need help with side images and imagebuttons

#3 Post by IsaacChambers »

Unfortunately I'm still getting the same error message after making the changes :(

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Need help with side images and imagebuttons

#4 Post by rayminator »

for your imagebuttons it should be something like this

Code: Select all

imagebutton:
            focus_mask True
            idle "bg_male_%s"
            hovered SetVariable("screen_tooltip", "male")
            unhovered SetVariable("screen_tooltip", "")
            action Jump ("choose_male")
I just tested the side images and it works fine for me

example only:

Code: Select all

define eileen = Character("Eileen", image="eileen")

image side eileen happy = "images/characters/avatars/sally/sally_affection_1.png"
image side eileen normal = "images/characters/avatars/roseanna/roseanna_affection_1.png"

label start:
    eileen happy "test"
    return

IsaacChambers
Newbie
Posts: 4
Joined: Sun May 22, 2022 1:04 pm
itch: Isaacchambers
Contact:

Re: Need help with side images and imagebuttons

#5 Post by IsaacChambers »

Thank you for the help Rayminator!
I made a little test project to use your code, and it worked perfectly

Code: Select all

define player = Character("Player", image="player")

image side player normal = "images/sideimages/side_male_normal.png"

label start:
    player normal "test"
    return
And it's made me be able to pinpoint that it's the line where you choose your own name that's messing things up.
So as soon as it looks like this, I get the same error message again:

Code: Select all

define player = Character("Player", image="player")

image side player normal = "images/sideimages/side_male_normal.png"

label start:
    $ player = renpy.input("What is your name?", default="Traveler", length=15)
    
    player normal "test"
    return

User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: Need help with side images and imagebuttons

#6 Post by RicharDann »

The problem is likely what you're doing in this line:

Code: Select all

$ player = renpy.input("What is your name?", default="Traveler", length=15)
It's assigning a new value to the already existing player variable, in this case the result of renpy.input() function. You're basically erasing the Character object stored in the variable and replacing it with a string produced when the player introduces as the character's new name.

You need to do instead something like this (I can't test at the moment but it should work):

Code: Select all

default player_name = "Player" #variable that will store the player's name

define player = Character("[player_name]", image="player") # Character object. Their name will be taken from the player_name variable

label start:

    # update the player_name variable with user's input. Added a strip() method to remove any trailing whitespace
    $ player_name = renpy.input("What is your name?", default="Traveler", length=15).strip()
    
    player normal "test"

    return
The most important step is always the next one.

IsaacChambers
Newbie
Posts: 4
Joined: Sun May 22, 2022 1:04 pm
itch: Isaacchambers
Contact:

Re: Need help with side images and imagebuttons

#7 Post by IsaacChambers »

With both of your advice I finally got it to work! TBH I removed the imagebutton for now and I will add that feature back at a later date.
For now I'm just happy to have my text show up with a side image.
Thank you both for solving my problem!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]