Imagebutton error [SOLVED]

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
Duchess
Regular
Posts: 61
Joined: Sat Aug 08, 2015 7:26 pm
Projects: Garden of Seif; Old Lucid9 Creative; Content Writer for VN Game Den
Organization: Foxdrift Studios
itch: foxdrift-studios
Location: Las Vegas
Contact:

Imagebutton error [SOLVED]

#1 Post by Duchess »

Hello! I'm using image buttons for my confirm screen. My code was originally created with text buttons, so I can't seem to figure out the right way to replace it with an image button.

Here is my current confirm screen code (I've hidden some of them during testing):

Code: Select all

screen confirm(message, yes_action, no_action):
    if message == layout.ARE_YOU_SURE:
        add "gui/overlay/confirm_areyousure.png"
        vbox align 1.0 yalign 1.0:
            imagebutton auto "gui/menubuttons/yes.png" action yes_action
            imagebutton auto "gui/menubuttons/no.png" action no_action
    
    #if message == layout.DELETE_SAVE:
        #add "gui/overlay/confirm_deletesave.png"
        #imagebutton auto "gui/menubuttons/yes.png" action yes_action
        #imagebutton auto "gui/menubuttons/no.png" action no_action
        
    #if message == layout.OVERWRITE_SAVE:
       # add "gui/overlay/confirm_overwritesave.png"
       # imagebutton auto "gui/menubuttons/yes.png" action yes_action
       # imagebutton auto "gui/menubuttons/no.png" action no_action
        
    #if message == layout.LOADING:
      #  add "gui/overlay/confirm_load.png"
       # imagebutton auto "gui/menubuttons/yes.png" action yes_action
       # imagebutton auto "gui/menubuttons/no.png" action no_action

   # if message == layout.QUIT:
       # add "gui/overlay/confirm_areyousure.png"
        ## imagebutton auto "gui/menubuttons/no.png" action no_action
        
    if message == layout.MAIN_MENU:
        add "gui/overlay/confirm_mainmenu.png"
        vbox xalign 1.0 yalign 1.0:
            imagebutton auto "gui/menubuttons/yes.png" action yes_action
            imagebutton auto "gui/menubuttons/no.png" action no_action
My latest error:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00gamemenu.rpy", line 173, in script
    $ ui.interact()
  File "renpy/common/00gamemenu.rpy", line 173, in <module>
    $ ui.interact()
  File "game/screens.rpy", line 949, in execute
    screen confirm(message, yes_action, no_action):
  File "game/screens.rpy", line 949, in execute
    screen confirm(message, yes_action, no_action):
  File "game/screens.rpy", line 975, in execute
    if message == layout.MAIN_MENU:
  File "game/screens.rpy", line 977, in execute
    vbox xalign 1.0 yalign 1.0:
  File "game/screens.rpy", line 978, in execute
    imagebutton auto "gui/menubuttons/yes.png" action yes_action
  File "renpy/common/00defaults.rpy", line 139, in _imagemap_auto_function
    rv = auto_param % variant
TypeError: not all arguments converted during string formatting

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

Full traceback:
  File "renpy/common/00gamemenu.rpy", line 173, in script
    $ ui.interact()
  File "renpy/ast.py", line 923, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "renpy/python.py", line 2235, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "renpy/common/00gamemenu.rpy", line 173, in <module>
    $ ui.interact()
  File "renpy/ui.py", line 298, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "renpy/display/core.py", line 3276, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, **kwargs)
  File "renpy/display/core.py", line 3694, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "renpy/display/core.py", line 568, in visit_all
    d.visit_all(callback, seen)
  File "renpy/display/core.py", line 568, in visit_all
    d.visit_all(callback, seen)
  File "renpy/display/core.py", line 568, in visit_all
    d.visit_all(callback, seen)
  File "renpy/display/core.py", line 568, in visit_all
    d.visit_all(callback, seen)
  File "renpy/display/screen.py", line 432, in visit_all
    callback(self)
  File "renpy/display/core.py", line 3694, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "renpy/display/screen.py", line 443, in per_interact
    self.update()
  File "renpy/display/screen.py", line 631, in update
    self.screen.function(**self.scope)
  File "game/screens.rpy", line 949, in execute
    screen confirm(message, yes_action, no_action):
  File "game/screens.rpy", line 949, in execute
    screen confirm(message, yes_action, no_action):
  File "game/screens.rpy", line 975, in execute
    if message == layout.MAIN_MENU:
  File "game/screens.rpy", line 977, in execute
    vbox xalign 1.0 yalign 1.0:
  File "game/screens.rpy", line 978, in execute
    imagebutton auto "gui/menubuttons/yes.png" action yes_action
  File "renpy/ui.py", line 952, in _imagebutton
    idle = choice(idle, idle_image, "idle", required=True)
  File "renpy/ui.py", line 940, in choice
    rv = renpy.config.imagemap_auto_function(auto, name)
  File "renpy/common/00defaults.rpy", line 139, in _imagemap_auto_function
    rv = auto_param % variant
TypeError: not all arguments converted during string formatting

Windows-10-10.0.19041
Ren'Py 7.4.8.1895
Garden of Seif 1.3
Sun Nov 14 11:07:45 2021
Last edited by Duchess on Fri Feb 25, 2022 6:58 pm, edited 1 time in total.
Duchess aka Suna back in the olden days.
https://foxdrift-studios.itch.io/garden-of-seif Just Making a visual novel about romance, assassins, a badass MC, and an anti-fairy godmother.

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

Re: Imagebutton error

#2 Post by rayminator »

edit the images that for those buttons and change them to a grey & white and use them as the hover and then edit the imagebutton code to idle and hover

if you want to try it this way...

Code: Select all

screen confirm(message, yes_action, no_action):
    if message == layout.ARE_YOU_SURE:
        add "gui/overlay/confirm_areyousure.png"
        vbox align 1.0 yalign 1.0:
            imagebutton idle "gui/menubuttons/yes.png" hover "gui/menubuttons/yes_h.png" action yes_action
            imagebutton idle "gui/menubuttons/no.png" hover "gui/menubuttons/no_h.png" action no_action

User avatar
Duchess
Regular
Posts: 61
Joined: Sat Aug 08, 2015 7:26 pm
Projects: Garden of Seif; Old Lucid9 Creative; Content Writer for VN Game Den
Organization: Foxdrift Studios
itch: foxdrift-studios
Location: Las Vegas
Contact:

Re: Imagebutton error

#3 Post by Duchess »

rayminator wrote: Sun Nov 14, 2021 3:25 pm edit the images that for those buttons and change them to a grey & white and use them as the hover and then edit the imagebutton code to idle and hover

if you want to try it this way...

Code: Select all

screen confirm(message, yes_action, no_action):
    if message == layout.ARE_YOU_SURE:
        add "gui/overlay/confirm_areyousure.png"
        vbox align 1.0 yalign 1.0:
            imagebutton idle "gui/menubuttons/yes.png" hover "gui/menubuttons/yes_h.png" action yes_action
            imagebutton idle "gui/menubuttons/no.png" hover "gui/menubuttons/no_h.png" action no_action
Thank you, it worked! Changed the vbox to hbox and adjusted the alignment so it was more centered and side by side.

Code: Select all

  if message == layout.MAIN_MENU:
        add "gui/overlay/confirm_mainmenu.png"
        hbox xalign 0.5 yalign 0.3:
            imagebutton idle "gui/menubuttons/yes_i.png" hover "gui/menubuttons/yes_h.png" action yes_action
            imagebutton idle "gui/menubuttons/no_i.png" hover "gui/menubuttons/no_h.png" action no_action
Duchess aka Suna back in the olden days.
https://foxdrift-studios.itch.io/garden-of-seif Just Making a visual novel about romance, assassins, a badass MC, and an anti-fairy godmother.

Post Reply

Who is online

Users browsing this forum: No registered users