'str' object is not callable

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
woogers
Newbie
Posts: 8
Joined: Tue Oct 02, 2012 9:02 pm
Location: Suburban America
Contact:

'str' object is not callable

#1 Post by woogers »

I've got a strange problem, where reloading the script with Shift+R or loading a saved game from a file through the save menu crashes the running game.

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game\script.rpy", line 13, in script
TypeError: 'str' object is not callable

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

Full traceback:
  File "C:\Users\user\Downloads\renpy-6.14.1-sdk\renpy\bootstrap.py", line 228, in bootstrap
  File "C:\Users\user\Downloads\renpy-6.14.1-sdk\renpy\main.py", line 342, in main
  File "C:\Users\user\Downloads\renpy-6.14.1-sdk\renpy\main.py", line 98, in run
  File "C:\Users\user\Downloads\renpy-6.14.1-sdk\renpy\execution.py", line 266, in run
  File "C:\Users\user\Downloads\renpy-6.14.1-sdk\renpy\ast.py", line 401, in execute
  File "C:\Users\user\Downloads\renpy-6.14.1-sdk\renpy\exports.py", line 750, in say
  File "C:\Users\user\Downloads\renpy-6.14.1-sdk\renpy\character.py", line 770, in __call__
  File "C:\Users\user\Downloads\renpy-6.14.1-sdk\renpy\character.py", line 664, in do_display
  File "C:\Users\user\Downloads\renpy-6.14.1-sdk\renpy\character.py", line 471, in display_say
  File "C:\Users\user\Downloads\renpy-6.14.1-sdk\renpy\ui.py", line 237, in interact
  File "C:\Users\user\Downloads\renpy-6.14.1-sdk\renpy\display\core.py", line 1813, in interact
  File "C:\Users\user\Downloads\renpy-6.14.1-sdk\renpy\display\core.py", line 2016, in interact_core
TypeError: 'str' object is not callable

Windows-7-6.1.7601-SP1
Ren'Py 6.14.1.366
Pre-game 0.2
The line in question is innocuous:

Code: Select all

grey "Nails."
Grey is shorthand (not really) for a pre-defined character:

Code: Select all

define grey = Character('Grey', color="#744358", show_two_window=True)
There shouldn't be a problem here, but there is. What am I doing wrong?

User avatar
Alex
Lemma-Class Veteran
Posts: 3098
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: 'str' object is not callable

#2 Post by Alex »

Have you changed your script after save file was made? Didn't you accidentally set "grey" variable to a string value later in your script?

woogers
Newbie
Posts: 8
Joined: Tue Oct 02, 2012 9:02 pm
Location: Suburban America
Contact:

Re: 'str' object is not callable

#3 Post by woogers »

No, the script has been the same for quite some time, and I didn't reassign the variable anywhere.

User avatar
Alex
Lemma-Class Veteran
Posts: 3098
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: 'str' object is not callable

#4 Post by Alex »

It is hard to tell what cause the error withuot seing more lines of code.
Try to change

Code: Select all

grey "Nails."
to

Code: Select all

"Nails."
to check if problem is in grey-character declaration. If the error will exist then the reason might be an overlay function or screen. Test it and show some more code maybe.

woogers
Newbie
Posts: 8
Joined: Tue Oct 02, 2012 9:02 pm
Location: Suburban America
Contact:

Re: 'str' object is not callable

#5 Post by woogers »

Removed grey from the line, the error traceback is still the same. What other code do you want to see?

User avatar
Alex
Lemma-Class Veteran
Posts: 3098
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: 'str' object is not callable

#6 Post by Alex »

Well, that means that problem is not in your character. Do you have any screens or overlay functions that are shown onscreen and might cause the error? And haven't you customized the say screen or quick menu in "screens.rpy"?

Levrex
Veteran
Posts: 280
Joined: Mon Jun 18, 2012 12:16 pm
Contact:

Re: 'str' object is not callable

#7 Post by Levrex »

Alex wrote:And haven't you customized the say screen or quick menu in "screens.rpy"?
*Clap* Eggs-ACTLY.

I remember seeing the same problem somewhere... what was it, again?

Also, woogers, let us take a peek at options.rpy file, not mentioning the screens.rpy one.
If your question is solved, please add [Solved] to theme's name by editing its first post, so that the helpful guys out there wouldn't mistakenly think the problem is still unanswered and waste their time.

woogers
Newbie
Posts: 8
Joined: Tue Oct 02, 2012 9:02 pm
Location: Suburban America
Contact:

Re: 'str' object is not callable

#8 Post by woogers »

My apologies for the weeks late reply, I've been busy with life things. Here is the options.rpy.

Code: Select all

## This file contains some of the options that can be changed to customize
## is quite a bit more customization you can do. 
##
## Lines beginning with two '#' marks are comments, and you shouldn't
## uncomment them. Lines beginning with a single '#' mark are
## commented-out code, and you may want to uncomment them when
## appropriate.

init -1 python hide:

    ## Should we enable the use of developer tools? This should be
    ## set to False before the game is released, so the user can't
    ## cheat using developer tools.

    config.developer = False

    ## These control the width and height of the screen.

    config.screen_width = 1280
    config.screen_height = 720

    ## This controls the title of the window, when Ren'Py is
    ## running in a window.

    config.window_title = u"MVP test"

    # These control the name and version of the game, that are reported
    # with tracebacks and other debugging logs.
    config.name = "MVP test ver"
    config.version = "5.2.2"

    #########################################
    # Themes
    
    ## We then want to call a theme function. themes.roundrect is
    ## a theme that features the use of rounded rectangles. It's
    ## the only theme we currently support.
    ##
    ## The theme function takes a number of parameters that can
    ## customize the color scheme.

    theme.tv(
        # Color scheme: Basic Blue
                                    
        ## The color of an idle widget face.
        widget = "#5a5a5a",

        ## The color of a focused widget face.
        widget_hover = "#3d3d3d",

        ## The color of the text in a widget.
        widget_text = "#cccccc",

        ## The color of the text in a selected widget. (For
        ## example, the current value of a preference.)
        widget_selected = "#ffffff",

        ## The color of a disabled widget face. 
        disabled = "242424",

        ## The color of disabled widget text.
        disabled_text = "#cdcdcd",

        ## The color of informational labels.
        label = "#ffffff",

        ## The color of a frame containing widgets.
        frame = "#999999",

        ## The background of the main menu. This can be a color
        ## beginning with '#', or an image filename. The latter
        ## should take up the full height and width of the screen.
        mm_root = "#cdcdcd",

        ## The background of the game menu. This can be a color
        ## beginning with '#', or an image filename. The latter
        ## should take up the full height and width of the screen.
        gm_root = "#5a5a5a",

        ## If this is True, the in-game window is rounded. If False,
        ## the in-game window is square.
        rounded_window = False,

        ## And we're done with the theme. The theme will customize
        ## various styles, so if we want to change them, we should
        ## do so below.            
        )


    #########################################
    ## These settings let you customize the window containing the
    ## dialogue and narration, by replacing it with an image.

    ## The background of the window. In a Frame, the two numbers
    ## are the size of the left/right and top/bottom borders,
    ## respectively.

    style.window.background = Frame("assets/ui/bg_textbox.png", 1, 1)

    ## Margin is space surrounding the window, where the background
    ## is not drawn.

    # style.window.left_margin = 6
    # style.window.right_margin = 6
    # style.window.top_margin = 6
    # style.window.bottom_margin = 6

    ## Padding is space inside the window, where the background is
    ## drawn.

    style.window.left_padding = 15
    style.window.right_padding = 15
    style.window.top_padding = 15
    style.window.bottom_padding = 15

    ## This is the minimum height of the window, including the margins
    ## and padding.

    style.window.yminimum = 175
    style.window.xminimum = 1280
    
    #style.window.xmaximum = 5

    #########################################
    ## This lets you change the placement of the main menu.

    ## The way placement works is that we find an anchor point
    ## inside a displayable, and a position (pos) point on the
    ## screen. We then place the displayable so the two points are
    ## at the same place.

    ## An anchor/pos can be given as an integer or a floating point
    ## number. If an integer, the number is interpreted as a number
    ## of pixels from the upper-left corner. If a floating point,
    ## the number is interpreted as a fraction of the size of the
    ## displayable or screen.

    # style.mm_menu_frame.xpos = 0.5
    # style.mm_menu_frame.xanchor = 0.5
    # style.mm_menu_frame.ypos = 0.75
    # style.mm_menu_frame.yanchor = 0.5


    #########################################
    ## These let you customize the default font used for text in Ren'Py.

    ## The file containing the default font.

    style.default.font = "assets/ui/fonts/Jura.ttf"

    ## The default size of text.

    style.default.size = 17

    ## Note that these only change the size of some of the text. Other
    ## buttons have their own styles.


    #########################################
    ## These settings let you change some of the sounds that are used by
    ## Ren'Py.

    ## Set this to False if the game does not have any sound effects.

    config.has_sound = True

    ## Set this to False if the game does not have any music.

    config.has_music = True

    ## Set this to False if the game does not have voicing.

    config.has_voice = False

    ## Sounds that are used when button and imagemaps are clicked.

    # style.button.activate_sound = "click.wav"
    # style.imagemap.activate_sound = "click.wav"

    ## Sounds that are used when entering and exiting the game menu.

    # config.enter_sound = "click.wav"
    # config.exit_sound = "click.wav"

    ## A sample sound that can be played to check the sound volume.

    # config.sample_sound = "click.wav"

    ## Music that is played while the user is at the main menu.

    config.main_menu_music = "assets/bgm/Menu Theme.ogg"


    #########################################
    ## Help.

    ## This lets you configure the help option on the Ren'Py menus.
    ## It may be:
    ## - A label in the script, in which case that label is called to
    ##   show help to the user.
    ## - A file name relative to the base directory, which is opened in a
    ##   web browser.
    ## - None, to disable help.   
    config.help = "README.html"


    #########################################
    ## Transitions.

    ## Used when entering the game menu from the game.
    config.enter_transition = None

    ## Used when exiting the game menu to the game.
    config.exit_transition = None

    ## Used between screens of the game menu.
    config.intra_transition = None

    ## Used when entering the game menu from the main menu.
    config.main_game_transition = None

    ## Used when returning to the main menu from the game.
    config.game_main_transition = None

    ## Used when entering the main menu from the splashscreen.
    config.end_splash_transition = None

    ## Used when entering the main menu after the game has ended.
    config.end_game_transition = None

    ## Used when a game is loaded.
    config.after_load_transition = "Fade"

    ## Used when the window is shown.
    config.window_show_transition = None

    ## Used when the window is hidden.
    config.window_hide_transition = None


    #########################################
    ## This is the name of the directory where the game's data is
    ## stored. (It needs to be set early, before any other init code
    ## is run, so the persisten information can be found by the init code.)
python early:
    config.save_directory = "renpy test"

init -1 python hide:
    #########################################
    ## Default values of Preferences.

    ## Note: These options are only evaluated the first time a
    ## game is run. To have them run a second time, delete
    ## game/saves/persistent

    ## Should we start in fullscreen mode?

    config.default_fullscreen = False

    ## The default text speed in characters per second. 0 is infinite.

    config.default_text_cps = 100

    #########################################
    ## More customizations can go here.
       
    ## Styles
    ## Transparent Background
    
    def custom_quit():
            Quit()()
    config.quit_action = custom_quit
    
init python:
     style.transp = Style(style.default)
     style.transp.background = "assets/ui/bg_transparent.png"
             
     style.tdim = Style(style.default)
     style.tdim.background = "assets/ui/bg_dimtransparent.png"
     
     config.window_icon = "assets/ui/logo.png"
     config.windows_icon = "assets/ui/logowin.png"
     
     

                         
## This section contains information about how to build your project into 
## distribution files.
init python:
    
    ## The name that's used for directories and archive files. For example, if
    ## this is 'mygame-1.0', the windows distribution will be in the
    ## directory 'mygame-1.0-win', in the 'mygame-1.0-win.zip' file.
    build.directory_name = "mvp test"
    
    ## The name that's uses for executables - the program that users will run
    ## to start the game. For example, if this is 'mygame', then on Windows,
    ## users can click 'mygame.exe' to start the game.
    build.executable_name = "mvp test"
    
    ## If True, Ren'Py will include update information into packages. This
    ## allows the updater to run.
    build.include_update = False
    
    ## File patterns:
    ## 
    ## The following functions take file patterns. File patterns are case-
    ## insensitive, and matched against the path relative to the base
    ## directory, with and without a leading /. If multiple patterns match,
    ## the first is used.
    ##    
    ##
    ## In a pattern:
    ##
    ## / 
    ##     Is the directory separator.
    ## *
    ##     Matches all characters, except the directory separator.
    ## **
    ##     Matches all characters, including the directory separator.
    ##
    ## For example:
    ##
    ## *.txt
    ##     Matches txt files in the base directory.
    ## game/**.ogg
    ##     Matches ogg files in the game directory or any of its subdirectories.
    ## **.psd
    ##    Matches psd files anywhere in the project.

    ## Classify files as None to exclude them from the built distributions.

    build.classify('**~', None)
    build.classify('**.bak', None)
    build.classify('**/.**', None)
    build.classify('**/#**', None)
    build.classify('**/thumbs.db', None)
    
    ## To archive files, classify them as 'archive'.
    
    # build.classify('game/**.png', 'archive')
    # build.classify('game/**.jpg', 'archive')

    ## Files matching documentation patterns are duplicated in a mac app
    ## build, so they appear in both the app and the zip file.

    build.documentation('*.html')
    build.documentation('*.txt')
    
    # Declare two archives.
    build.archive("scripts", "all")
    build.archive("assets", "all")

    # Put script files into the scripts archive.
    build.classify("game/**.rpy", "scripts")
    build.classify("game/**.rpyc", "scripts")

    # Put images into the images archive.
    build.classify("game/**.jpg", "assets")
    build.classify("game/**.png", "assets")
    build.classify("game/**.ogg", "assets")
    build.classify("game/**.ttf", "assets")
    

Levrex
Veteran
Posts: 280
Joined: Mon Jun 18, 2012 12:16 pm
Contact:

Re: 'str' object is not callable

#9 Post by Levrex »

Options seem fine to me.

Except for one little mistake.

Code: Select all

config.after_load_transition = "Fade"
^ That shouldn't be a string (i mean, remove quotes). If you defined a "Fade", that should work. If not, you'd have to set fade properties first (maybe). http://www.renpy.org/wiki/renpy/doc/ref ... tions/Fade
If your question is solved, please add [Solved] to theme's name by editing its first post, so that the helpful guys out there wouldn't mistakenly think the problem is still unanswered and waste their time.

woogers
Newbie
Posts: 8
Joined: Tue Oct 02, 2012 9:02 pm
Location: Suburban America
Contact:

Re: 'str' object is not callable

#10 Post by woogers »

Fixed that, loading is still broken. ;_;

I'll keep messing with things. Thanks for the help!

Levrex
Veteran
Posts: 280
Joined: Mon Jun 18, 2012 12:16 pm
Contact:

Re: 'str' object is not callable

#11 Post by Levrex »

Traceback message changed, i hope?

===

That means something else is broken too.
But to find that i need to take a look at your game.
If your question is solved, please add [Solved] to theme's name by editing its first post, so that the helpful guys out there wouldn't mistakenly think the problem is still unanswered and waste their time.

Post Reply

Who is online

Users browsing this forum: Bmac60506