Script error 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
vitum
Newbie
Posts: 10
Joined: Mon Feb 20, 2012 3:33 pm
Contact:

Script error and imagebuttons

#1 Post by vitum »

I've been working on this script for awhile and there's always something wrong with it but I think I have it now except....for this one error

Code: Select all

 You can place the script of your game in this file.

# Declare images below this line, using the image statement.
image bed = "bedroomday.png"
image class = "classroomday.png"
image hall = "hallwayday.png"
image stairs = "hstairsday.png"
image room = "roomday.png"
image school = "schoolday.png"
image nurse = "nurseday.png"
image up = "GreenButton_UpArrow.svg.png"
image down = "GreenButton_DownArrow.svg.png"
image left = "GreenButton_LeftArrow.svg.png"
image right = "GreenButton_RightArrow.svg.png"
# Declare characters used by this game.

init:
 $ esubtitle = Character(None,
                            what_size=28,
                            what_outlines=[(3, "#0008", 2, 2), (3, "#000", 0, 0)],
                            what_layout="subtitle",
                            what_xalign=0.5,
                            what_text_align=0.5,
                            window_background=None,
                            window_yminimum=0,
                            window_xfill=False,
                            window_xalign=0.5)
 screen NRJ:
     text "Energy 10/10"
screen hp:
    text "Energy 9/10"
screen scan:
    textbutton "Scan" action Jump("read") 
screen lets_go:
    imagebutton auto "GreenButton_UpArrow.svg.png" action Jump("up") (693, 479, 59, 32) 
    imagebutton auto "GreenButton_DownArrow.svg.png" action Jump("down") (696, 563, 59, 32)
    imagebutton auto "GreenButton_LeftArrow.svg.png" action Jump("left") (627, 518, 59, 32)
    imagebutton auto "GreenButton_RightArrow.svg.png" action Jump("right") (726, 513, 59, 32)
    # The game starts here.
label start:
    scene school
    show screen NRJ
    esubtitle "Welcome to the Anarchy Institute."
    esubtitle "Go ahead inside..."
    show screen lets_go
label up:
    scene room
    show screen hp
    show screen scan
    esubtitle "I wonder what this room is for."
label read:
    esubtitle "This is it?"
label down:
    scene stairs
    esubtitle "I wonder where these stairs go..."
    esubtitle "Hmmm.."
    
label left:
    scene nurse
    esubtitle "The nurse.."
label right:
    scene hall
    esubtitle "The classes must be down this hall."
And this is the error

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 50, in script
        esubtitle "I wonder what this room is for."
  File "game/script.rpy", line 35, in python
        imagebutton auto "GreenButton_UpArrow.svg.png" action Jump("up") (693, 479, 59, 32) 
TypeError: __call__() takes exactly 1 argument (5 given)

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

Full traceback:
  File "F:\renpy-6.13.7\renpy\execution.py", line 261, in run
  File "F:\renpy-6.13.7\renpy\ast.py", line 396, in execute
  File "F:\renpy-6.13.7\renpy\exports.py", line 696, in say
  File "F:\renpy-6.13.7\renpy\character.py", line 770, in __call__
  File "F:\renpy-6.13.7\renpy\character.py", line 664, in do_display
  File "F:\renpy-6.13.7\renpy\character.py", line 471, in display_say
  File "F:\renpy-6.13.7\renpy\ui.py", line 237, in interact
  File "F:\renpy-6.13.7\renpy\display\core.py", line 1798, in interact
  File "F:\renpy-6.13.7\renpy\display\core.py", line 2036, in interact_core
  File "F:\renpy-6.13.7\renpy\display\core.py", line 246, in visit_all
  File "F:\renpy-6.13.7\renpy\display\core.py", line 246, in visit_all
  File "F:\renpy-6.13.7\renpy\display\core.py", line 246, in visit_all
  File "F:\renpy-6.13.7\renpy\display\core.py", line 248, in visit_all
  File "F:\renpy-6.13.7\renpy\display\core.py", line 2036, in <lambda>
  File "F:\renpy-6.13.7\renpy\display\screen.py", line 152, in per_interact
  File "F:\renpy-6.13.7\renpy\display\screen.py", line 244, in update
  File "F:\renpy-6.13.7\renpy\screenlang.py", line 1166, in __call__
  File "F:\renpy-6.13.7\renpy\python.py", line 978, in py_exec_bytecode
  File "game/script.rpy", line 35, in <module>
TypeError: __call__() takes exactly 1 argument (5 given)

Windows-Vista-6.0.6000
Ren'Py 6.13.7.1646
A Ren'Py Game 0.0
So my question is what's the error and are the imagebuttons right? And are there any other mistakes?

Thanks
Last edited by vitum on Sun Mar 25, 2012 5:38 pm, edited 1 time in total.

Anima
Veteran
Posts: 448
Joined: Wed Nov 18, 2009 11:17 am
Completed: Loren
Projects: PS2
Location: Germany
Contact:

Re: Script error and imagebuttons

#2 Post by Anima »

Your imagebutton declarations are wrong, try it this way:

Code: Select all

imagebutton auto "GreenButton_UpArrow.svg.png" action Jump("up") area (693, 479, 59, 32) 
Avatar created with this deviation by Crysa
Currently working on:
  • Winterwolves "Planet Stronghold 2" - RPG Framework: Phase III

vitum
Newbie
Posts: 10
Joined: Mon Feb 20, 2012 3:33 pm
Contact:

Re: Script error and imagebuttons

#3 Post by vitum »

I tried that and got this error

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 50, in script
        esubtitle "I wonder what this room is for."
  File "game/script.rpy", line 35, in python
        imagebutton auto "GreenButton_UpArrow.svg.png" action Jump("up") area (693, 479, 59, 32) 
TypeError: not all arguments converted during string formatting

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

Full traceback:
  File "F:\renpy-6.13.7\renpy\execution.py", line 261, in run
  File "F:\renpy-6.13.7\renpy\ast.py", line 396, in execute
  File "F:\renpy-6.13.7\renpy\exports.py", line 696, in say
  File "F:\renpy-6.13.7\renpy\character.py", line 770, in __call__
  File "F:\renpy-6.13.7\renpy\character.py", line 664, in do_display
  File "F:\renpy-6.13.7\renpy\character.py", line 471, in display_say
  File "F:\renpy-6.13.7\renpy\ui.py", line 237, in interact
  File "F:\renpy-6.13.7\renpy\display\core.py", line 1798, in interact
  File "F:\renpy-6.13.7\renpy\display\core.py", line 2036, in interact_core
  File "F:\renpy-6.13.7\renpy\display\core.py", line 246, in visit_all
  File "F:\renpy-6.13.7\renpy\display\core.py", line 246, in visit_all
  File "F:\renpy-6.13.7\renpy\display\core.py", line 246, in visit_all
  File "F:\renpy-6.13.7\renpy\display\core.py", line 248, in visit_all
  File "F:\renpy-6.13.7\renpy\display\core.py", line 2036, in <lambda>
  File "F:\renpy-6.13.7\renpy\display\screen.py", line 152, in per_interact
  File "F:\renpy-6.13.7\renpy\display\screen.py", line 244, in update
  File "F:\renpy-6.13.7\renpy\screenlang.py", line 1166, in __call__
  File "F:\renpy-6.13.7\renpy\python.py", line 978, in py_exec_bytecode
  File "game/script.rpy", line 35, in <module>
  File "F:\renpy-6.13.7\renpy\ui.py", line 435, in __call__
  File "F:\renpy-6.13.7\renpy\ui.py", line 695, in _imagebutton
  File "F:\renpy-6.13.7\renpy\ui.py", line 691, in choice
  File "common/00library.rpy", line 380, in imagemap_auto_function
TypeError: not all arguments converted during string formatting

Windows-Vista-6.0.6000
Ren'Py 6.13.7.1646
A Ren'Py Game 0.0

Anima
Veteran
Posts: 448
Joined: Wed Nov 18, 2009 11:17 am
Completed: Loren
Projects: PS2
Location: Germany
Contact:

Re: Script error and imagebuttons

#4 Post by Anima »

The problem is your usage of auto, Ren'Py expects the image name string to interpolate the button state.
Look here in the documentation for examples and a further explanation.
Avatar created with this deviation by Crysa
Currently working on:
  • Winterwolves "Planet Stronghold 2" - RPG Framework: Phase III

vitum
Newbie
Posts: 10
Joined: Mon Feb 20, 2012 3:33 pm
Contact:

Re: Script error and imagebuttons

#5 Post by vitum »

Ok so do I have to use selected idle, selected hover, hovered and unhovered or can I keep it like this,

Code: Select all

screen lets_go:
    imagebutton idle "up_arrow.jpg" action Jump('up') area (693, 479, 59, 32)
    imagebutton hover "up_arrow.jpg" action Jump('up') area  (693, 479, 59, 32)
    imagebutton idle "down_arrow.jpg" action Jump('down') area  (696, 563, 59, 32)
    imagebutton hover "down_arrow.jpg" action Jump('down') area (696, 563, 59, 32)
    imagebutton idle "left_arrow.jpg" action Jump('left') area  (627, 518, 59, 32)
    imagebutton hover "left_arrow.jpg" action Jump('left') area  (627, 518, 59, 32)
    imagebutton idle "right_arrow.jpg" action Jump('right')  area (726, 513, 59, 32)
    imagebutton hover "right_arrow.jpg" action Jump('right') area (726, 513, 59, 32)
This is the error

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 54, in script
        esubtitle "I wonder what this room is for."
  File "game/script.rpy", line 35, in python
        imagebutton idle "up_arrow.jpg" action Jump('up') area (693, 479, 59, 32)
Exception: Not a displayable: None

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

Full traceback:
  File "F:\renpy-6.13.7\renpy\execution.py", line 261, in run
  File "F:\renpy-6.13.7\renpy\ast.py", line 396, in execute
  File "F:\renpy-6.13.7\renpy\exports.py", line 696, in say
  File "F:\renpy-6.13.7\renpy\character.py", line 770, in __call__
  File "F:\renpy-6.13.7\renpy\character.py", line 664, in do_display
  File "F:\renpy-6.13.7\renpy\character.py", line 471, in display_say
  File "F:\renpy-6.13.7\renpy\ui.py", line 237, in interact
  File "F:\renpy-6.13.7\renpy\display\core.py", line 1798, in interact
  File "F:\renpy-6.13.7\renpy\display\core.py", line 2036, in interact_core
  File "F:\renpy-6.13.7\renpy\display\core.py", line 246, in visit_all
  File "F:\renpy-6.13.7\renpy\display\core.py", line 246, in visit_all
  File "F:\renpy-6.13.7\renpy\display\core.py", line 246, in visit_all
  File "F:\renpy-6.13.7\renpy\display\core.py", line 248, in visit_all
  File "F:\renpy-6.13.7\renpy\display\core.py", line 2036, in <lambda>
  File "F:\renpy-6.13.7\renpy\display\screen.py", line 152, in per_interact
  File "F:\renpy-6.13.7\renpy\display\screen.py", line 244, in update
  File "F:\renpy-6.13.7\renpy\screenlang.py", line 1166, in __call__
  File "F:\renpy-6.13.7\renpy\python.py", line 978, in py_exec_bytecode
  File "game/script.rpy", line 35, in <module>
  File "F:\renpy-6.13.7\renpy\ui.py", line 435, in __call__
  File "F:\renpy-6.13.7\renpy\ui.py", line 711, in _imagebutton
  File "F:\renpy-6.13.7\renpy\display\behavior.py", line 682, in __init__
  File "F:\renpy-6.13.7\renpy\easy.py", line 129, in displayable
Exception: Not a displayable: None

Windows-Vista-6.0.6000
Ren'Py 6.13.7.1646
A Ren'Py Game 0.0

Anima
Veteran
Posts: 448
Joined: Wed Nov 18, 2009 11:17 am
Completed: Loren
Projects: PS2
Location: Germany
Contact:

Re: Script error and imagebuttons

#6 Post by Anima »

Okay, let's start with a simpler button concept and go to the full imagebutton from there.
Try the following:

Code: Select all

button:
    background "up_arrow.jpg"
    area (693, 479, 59, 32)
    action Jump('up')
That should get you a working button at the least.
Avatar created with this deviation by Crysa
Currently working on:
  • Winterwolves "Planet Stronghold 2" - RPG Framework: Phase III

vitum
Newbie
Posts: 10
Joined: Mon Feb 20, 2012 3:33 pm
Contact:

Re: Script error and imagebuttons

#7 Post by vitum »

So is this the only way to make direction buttons? Or is there another way?

Post Reply

Who is online

Users browsing this forum: Google [Bot]