Imagebutton can't find defined image?

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
User avatar
fullmontis
Regular
Posts: 129
Joined: Sun May 05, 2013 8:03 am
Deviantart: fullmontis
itch: fullmontis
Location: Italy
Contact:

Imagebutton can't find defined image?

#1 Post by fullmontis »

What the following code is trying to do (and failing) is creating an imagebutton so that, when hovered, a small animation in ATL starts playing.

Code: Select all

init -2:
    image startimage = "start0.png"

    image startimage_hover:
        "start0.png"
        pause 0.1
        "start1.png"
        pause 0.1
        "start2.png"
        pause 0.1
        repeat

    transform menubutton(x,y):
        xcenter x
        ycenter y
        on idle:
            easein 0.5 zoom 1.0
        on hover:
            easein 0.5 zoom 1.2

screen test:
    imagebutton idle startimage hover startimage_hover at menubutton(304,161) action Start()

label start:
    show screen test

However, when trying to run the code I get the following error.

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 136, in execute
    screen prova:
  File "game/script.rpy", line 136, in execute
    screen prova:
  File "game/script.rpy", line 137, in execute
    imagebutton idle "start0.png" hover startimage_hover at menubutton(304,161) action Start()
  File "game/script.rpy", line 137, in keywords
    imagebutton idle "start0.png" hover startimage_hover at menubutton(304,161) action Start()
NameError: name 'startimage' is not defined

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

Full traceback:
  File "/home/andrea/script.rpyc", line 166, in script
  File "/home/andrea/renpy/renpy/ast.py", line 613, in execute
    renpy.exports.say(who, what, interact=self.interact)
  File "/home/andrea/renpy/renpy/exports.py", line 1147, in say
    who(what, interact=interact)
  File "/home/andrea/renpy/renpy/character.py", line 877, in __call__
    self.do_display(who, what, cb_args=self.cb_args, **display_args)
  File "/home/andrea/renpy/renpy/character.py", line 716, in do_display
    **display_args)
  File "/home/andrea/renpy/renpy/character.py", line 508, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "/home/andrea/renpy/renpy/ui.py", line 285, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "/home/andrea/renpy/renpy/display/core.py", line 2507, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "/home/andrea/renpy/renpy/display/core.py", line 2774, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "/home/andrea/renpy/renpy/display/core.py", line 495, in visit_all
    d.visit_all(callback)
  File "/home/andrea/renpy/renpy/display/core.py", line 495, in visit_all
    d.visit_all(callback)
  File "/home/andrea/renpy/renpy/display/core.py", line 495, in visit_all
    d.visit_all(callback)
  File "/home/andrea/renpy/renpy/display/screen.py", line 399, in visit_all
    callback(self)
  File "/home/andrea/renpy/renpy/display/core.py", line 2774, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "/home/andrea/renpy/renpy/display/screen.py", line 409, in per_interact
    self.update()
  File "/home/andrea/renpy/renpy/display/screen.py", line 578, in update
    self.screen.function(**self.scope)
  File "game/script.rpy", line 136, in execute
    screen prova:
  File "game/script.rpy", line 136, in execute
    screen prova:
  File "game/script.rpy", line 137, in execute
    imagebutton idle "start0.png" hover startimage_hover at menubutton(304,161) action Start()
  File "game/script.rpy", line 137, in keywords
    imagebutton idle "start0.png" hover startimage_hover at menubutton(304,161) action Start()
  File "<screen language>", line 137, in <module>
NameError: name 'startimage' is not defined

Linux-4.4.0-64-generic-i686-with-debian-stretch-sid
Ren'Py 6.99.12.3.2123
explore 1.0
I don't understand why it can't find the definition, since the images should be defined before the screen. Any help?

EDIT: fixed source

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

Re: Imagebutton can't find defined image?

#2 Post by Ocelot »

Code: Select all

screen test:
    imagebutton idle 'startimage' hover 'startimage_hover' at menubutton(304,161) action Start()
< < insert Rick Cook quote here > >

User avatar
fullmontis
Regular
Posts: 129
Joined: Sun May 05, 2013 8:03 am
Deviantart: fullmontis
itch: fullmontis
Location: Italy
Contact:

Re: Imagebutton can't find defined image?

#3 Post by fullmontis »

Well, that was easy. Silly me :oops:
Thank you for the help

Post Reply

Who is online

Users browsing this forum: Google [Bot], Ocelot