TypeError: '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
ArizaLuca
Veteran
Posts: 241
Joined: Tue Feb 20, 2018 12:59 pm
Completed: Through the Screen, Riddle Me This, Trust Fall, Phobias, Another Adventure
Projects: The Souls in the Seams, Fata Morgana, Minecraft: Story Mode - Behind the Scenes
Organization: Astral Autumn Games
Tumblr: astralautumngames
Deviantart: ArizaLuca
itch: astralautumngames
Contact:

TypeError: 'str' object is not callable

#1 Post by ArizaLuca »

Code: Select all

I'm sorry, but an uncaught exception occurred.

Compiling ATL code at game/script.rpy:25
  File "game/script.rpy", line 340, in script
    
TypeError: 'str' object is not callable

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

Full traceback:
  File "game/script.rpy", line 340, in script
    
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/ast.py", line 1310, in execute
    renpy.exports.with_statement(trans, paired)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/exports.py", line 1409, in with_statement
    return renpy.game.interface.do_with(trans, paired, clear=clear)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/core.py", line 2190, in do_with
    clear=clear)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/core.py", line 2624, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/core.py", line 3098, in interact_core
    self.draw_screen(root_widget, fullscreen_video, (not fullscreen_video) or video_frame_drawn)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/core.py", line 2038, in draw_screen
    renpy.config.screen_height,
  File "render.pyx", line 485, in renpy.display.render.render_screen
  File "render.pyx", line 233, in renpy.display.render.render
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/layout.py", line 711, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 145, in renpy.display.render.render
  File "render.pyx", line 233, in renpy.display.render.render
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/transition.py", line 361, in render
    top = render(self.new_widget, width, height, st, at)
  File "render.pyx", line 145, in renpy.display.render.render
  File "render.pyx", line 233, in renpy.display.render.render
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/layout.py", line 711, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 145, in renpy.display.render.render
  File "render.pyx", line 233, in renpy.display.render.render
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/layout.py", line 711, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 145, in renpy.display.render.render
  File "render.pyx", line 233, in renpy.display.render.render
  File "accelerator.pyx", line 108, in renpy.display.accelerator.transform_render
  File "render.pyx", line 233, in renpy.display.render.render
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/image.py", line 414, in render
    return wrap_render(self.target, width, height, st, at)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/image.py", line 229, in wrap_render
    rend = render(child, w, h, st, at)
  File "render.pyx", line 145, in renpy.display.render.render
  File "render.pyx", line 233, in renpy.display.render.render
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/layout.py", line 325, in render
    surf = render(self.child, width, height, st, at)
  File "render.pyx", line 145, in renpy.display.render.render
  File "render.pyx", line 233, in renpy.display.render.render
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/layout.py", line 1251, in render
    self.update(st, at)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/layout.py", line 1240, in update
    child.visit_all(lambda c : c.per_interact())
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/core.py", line 511, in visit_all
    d.visit_all(callback)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/core.py", line 508, in visit_all
    for d in self.visit():
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/atl.py", line 569, in visit
    block = self.compile()
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/atl.py", line 481, in compile
    block = self.atl.compile(self.context)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/atl.py", line 671, in compile
    statements = [ i.compile(ctx) for i in self.statements ]
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/atl.py", line 884, in compile
    child = ctx.eval(expr)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/atl.py", line 246, in eval
    return eval(expr, renpy.store.__dict__, self.context)  # @UndefinedVariable
  File "<string>", line 4, in <module>
TypeError: 'str' object is not callable

Darwin-17.2.0-x86_64-i386-64bit
Ren'Py 6.99.14.1.3218
LGBTQ Game 1.0
Thu May 31 17:20:04 2018
In the code somewhere, I have a:

Code: Select all

show terry
with dissolve
but when I put in the LiveComposite and ConditionSwitch images, for some reason it stopped working. The code for those is here:

Code: Select all

image terry_human:
    LiveComposite(
        (480, 720),
        (0,0), "terry human.png"
        (0,0), ConditionSwitch(
            "t_face == 'happy'", "terry happy.png",
            "t_face == 'sad'", "terry sad.png",
            "t_face == 'surprised'", "terry surprised.png",
            "t_face == 'thoughtful'", "terry thoughtful.png",
            "True", "terry normal.png",
            )
        )
    
image terry_monster:
    LiveComposite(
        (480, 720),
        (0,0), "terry monster.png"
        (0,0), ConditionSwitch(
            "t_face == 'happy'", "terry happy.png",
            "t_face == 'sad'", "terry sad.png",
            "t_face == 'surprised'", "terry surprised.png",
            "t_face == 'thoughtful'", "terry thoughtful.png",
            "True", "terry normal.png",
            )
        )
    
image terry_half:
    LiveComposite(
        (480, 720),
        (0,0), "terry half.png"
        (0,0), ConditionSwitch(
            "t_face == 'happy'", "terry happy.png",
            "t_face == 'sad'", "terry sad.png",
            "t_face == 'surprised'", "terry surprised.png",
            "t_face == 'thoughtful'", "terry thoughtful.png",
            "True", "terry normal.png",
            )
        )

image terry = ConditionSwitch(
    "terry == 'human'", "terry_human",
    "terry == 'monster'", "terry_monster",
    "terry == 'half'", "terry_half",
    "True", "terry_human",
    )
What is the problem?

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: TypeError: 'str' object is not callable

#2 Post by kivik »

Just guessing here:

Since that line is show terry - and the error is that str object is not callable - I think the problem is that it's not treating "terry_human", "terry_monster" and "terry_half" as displayables but strings. I could be wrong but I did a quick google and it looks like all instances, an image file is referenced in that part of the conditionswitch, so perhaps it doesn't interpret the string as the image you've defined.

With that in mind - perhaps a quick fix is doing show expression "terry_%s" % terry?

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: TypeError: 'str' object is not callable

#3 Post by philat »

No, ConditionSwitch takes displayables. Probably comma errors. (Missing comma inside LiveComposite right before the ConditionSwitch, specifically.)

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: TypeError: 'str' object is not callable

#4 Post by kivik »

So easy to see once you say it philat!

ArizaLuca
Veteran
Posts: 241
Joined: Tue Feb 20, 2018 12:59 pm
Completed: Through the Screen, Riddle Me This, Trust Fall, Phobias, Another Adventure
Projects: The Souls in the Seams, Fata Morgana, Minecraft: Story Mode - Behind the Scenes
Organization: Astral Autumn Games
Tumblr: astralautumngames
Deviantart: ArizaLuca
itch: astralautumngames
Contact:

Re: TypeError: 'str' object is not callable

#5 Post by ArizaLuca »

Ah, thank you!

Post Reply

Who is online

Users browsing this forum: No registered users