[solved] TypeError: unbound method get_tooltip() must be called with Return instance as first argument (got nothing

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
ComputerArt.Club
Veteran
Posts: 409
Joined: Mon May 22, 2017 8:12 am
Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
Location: Taiwan
Contact:

[solved] TypeError: unbound method get_tooltip() must be called with Return instance as first argument (got nothing

#1 Post by ComputerArt.Club » Fri Aug 02, 2019 11:02 am

After finishing a quiz in my story I am getting an error: TypeError: unbound method get_tooltip() must be called with Return instance as first argument (got nothing instead) [Full traceback below]

I was trying to shorten and reuse code for each question in a quiz, and so I define my variables for each section, call a reusable section. I think the problem is that most of the time the call command never gets to go back to the point at which it was called as, depending on the quiz answer, the section can end with a jump command. An incorrect quiz answer will utilize the call command and return to where it came from.

Code: Select all

label q2question17:
label .qstart:
    #there is code here but it is unrelated, confusing, and probably unlikely to be a problem in this case
    call winorlose
    jump .qstart
    
label winorlose:
    call screen wordst
    $ result = _return

    if result == "win": 
        play sound "duck.mp3"
        call win
        jump quiz2 #My guess is that this is the problem, call winorlose is probably trying to keep track of where it needs to return to, but never gets a chance.
    else: #this else code uses the call function properly and goes back
        play sound "wrongduck.mp3"
Do you think it is the call command?
Should I bite the bullet and just add the winorlose code to each of the questions and thus get rid of the call function, or is there another way?
I'd really love to be able to keep code lean.

I looked at the Patreon articles with creator defined statements, and I saw blocks were included, but they don't seem to be reused/called and seem to exist within their specific label.

Thanks for taking the time to read this!!! :D
Traceback:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/quiz2.rpy", line 164, in script call
    call winorlose
  File "game/quiz2.rpy", line 76, in script call
    call winorlose
  File "game/quiz2.rpy", line 109, in script call
    call winorlose
  File "game/quiz2.rpy", line 219, in script call
    call winorlose
  File "game/quiz2.rpy", line 208, in script call
    call winorlose
  File "game/quiz2.rpy", line 98, in script call
    call winorlose
  File "game/quiz2.rpy", line 153, in script call
    call winorlose
  File "game/quiz2.rpy", line 87, in script call
    call winorlose
  File "game/quiz2.rpy", line 142, in script call
    call winorlose
  File "game/quiz2.rpy", line 131, in script call
    call winorlose
  File "game/quiz2.rpy", line 175, in script call
    call winorlose
  File "game/quiz2.rpy", line 65, in script call
    call winorlose
  File "game/quiz2.rpy", line 54, in script call
    call winorlose
  File "game/quiz2.rpy", line 120, in script call
    call winorlose
  File "game/quiz2.rpy", line 186, in script call
    call winorlose
  File "game/quiz2.rpy", line 197, in script call
    call winorlose
  File "game/script.rpy", line 760, in script
    call screen rate
  File "renpy/common/000statements.rpy", line 531, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
TypeError: unbound method get_tooltip() must be called with Return instance as first argument (got nothing instead)

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

Full traceback:
  File "game/quiz2.rpy", line 164, in script call
    call winorlose
  File "game/quiz2.rpy", line 76, in script call
    call winorlose
  File "game/quiz2.rpy", line 109, in script call
    call winorlose
  File "game/quiz2.rpy", line 219, in script call
    call winorlose
  File "game/quiz2.rpy", line 208, in script call
    call winorlose
  File "game/quiz2.rpy", line 98, in script call
    call winorlose
  File "game/quiz2.rpy", line 153, in script call
    call winorlose
  File "game/quiz2.rpy", line 87, in script call
    call winorlose
  File "game/quiz2.rpy", line 142, in script call
    call winorlose
  File "game/quiz2.rpy", line 131, in script call
    call winorlose
  File "game/quiz2.rpy", line 175, in script call
    call winorlose
  File "game/quiz2.rpy", line 65, in script call
    call winorlose
  File "game/quiz2.rpy", line 54, in script call
    call winorlose
  File "game/quiz2.rpy", line 120, in script call
    call winorlose
  File "game/quiz2.rpy", line 186, in script call
    call winorlose
  File "game/quiz2.rpy", line 197, in script call
    call winorlose
  File "game/script.rpy", line 760, in script
    call screen rate
  File "X:\games\renpy\renpy-7.3.2-sdk\renpy\ast.py", line 1947, in execute
    self.call("execute")
  File "X:\games\renpy\renpy-7.3.2-sdk\renpy\ast.py", line 1935, in call
    return renpy.statements.call(method, parsed, *args, **kwargs)
  File "X:\games\renpy\renpy-7.3.2-sdk\renpy\statements.py", line 277, in call
    return method(parsed, *args, **kwargs)
  File "renpy/common/000statements.rpy", line 531, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
  File "X:\games\renpy\renpy-7.3.2-sdk\renpy\exports.py", line 2896, in call_screen
    rv = renpy.ui.interact(mouse="screen", type="screen", roll_forward=roll_forward)
  File "X:\games\renpy\renpy-7.3.2-sdk\renpy\ui.py", line 295, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "X:\games\renpy\renpy-7.3.2-sdk\renpy\display\core.py", line 2699, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "X:\games\renpy\renpy-7.3.2-sdk\renpy\display\core.py", line 3507, in interact_core
    rv = renpy.display.focus.mouse_handler(ev, x, y)
  File "X:\games\renpy\renpy-7.3.2-sdk\renpy\display\focus.py", line 407, in mouse_handler
    return change_focus(new_focus, default=default)
  File "X:\games\renpy\renpy-7.3.2-sdk\renpy\display\focus.py", line 362, in change_focus
    set_focused(current, newfocus.arg, newfocus.screen)
  File "X:\games\renpy\renpy-7.3.2-sdk\renpy\display\focus.py", line 109, in set_focused
    new_tooltip = widget._get_tooltip()
  File "X:\games\renpy\renpy-7.3.2-sdk\renpy\display\behavior.py", line 746, in _get_tooltip
    return get_tooltip(self.action)
  File "X:\games\renpy\renpy-7.3.2-sdk\renpy\display\behavior.py", line 373, in get_tooltip
    return func()
TypeError: unbound method get_tooltip() must be called with Return instance as first argument (got nothing instead)

Windows-7-6.1.7601-SP1
Ren'Py 7.3.2.320
Cats Bath Test 2 1.0
Fri Aug 02 15:34:13 2019
Last edited by ComputerArt.Club on Sat Aug 03, 2019 3:26 am, edited 1 time in total.

User avatar
gas
Veteran
Posts: 451
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: TypeError: unbound method get_tooltip() must be called with Return instance as first argument (got nothing instead)

#2 Post by gas » Fri Aug 02, 2019 7:49 pm

No. The Call stack just stack the calls expecting a Return at any point in the future , so jumping elsewhere doesn't throw errors.
I think the issue is elsewhere (probably such screen).

Anyway, to make a VERY lean code, you should abstract the code some more.
Make a core routine, that call the proper question (a list could be the best mode), register the reply and return.
Then call the correct success/fail label and return.
Repeat the core routine.

Something like this:

Code: Select all

default questions = ["quest1","quest2"]
default quest_index = 0

label core:
    $ success = False # default to False, set to True if you'll give the correct answer
    $ thequestion = questions[quest_index] # The question label we'll process
    call expression thequestion # this call a label based on an expression
    if success:
        call correct_reply # <- This manage when an answer is correct
    else:
        call wrong_reply # <- This manage when an answer is wrong
    $ quest_index += 1 # the next question to process ...
    # probably there use a check to verify if any question left, if none jump to the end of the quiz.
    jump core

### Question example
label quest1:
    # .. the questions
    # You can call a screen with parameters (question, answers, and what they return) to abstract it.
    # call screen quiz (question="Who does it?", a1=("blabla", True), a2=("blueblue", False), a3=("globglob", False))
    # The answer return a Flag (True or False).
    $ success = _return
    return
    
Just proxy code. Anyway this should help you greatly in the debug phase.
10 ? "RENPY"
20 GOTO 10

RUN

User avatar
ComputerArt.Club
Veteran
Posts: 409
Joined: Mon May 22, 2017 8:12 am
Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
Location: Taiwan
Contact:

Re: TypeError: unbound method get_tooltip() must be called with Return instance as first argument (got nothing instead)

#3 Post by ComputerArt.Club » Sat Aug 03, 2019 3:24 am

gas wrote:
Fri Aug 02, 2019 7:49 pm
No. The Call stack just stack the calls expecting a Return at any point in the future , so jumping elsewhere doesn't throw errors.
I think the issue is elsewhere (probably such screen).

Anyway, to make a VERY lean code, you should abstract the code some more.
Make a core routine, that call the proper question (a list could be the best mode), register the reply and return.
Then call the correct success/fail label and return.
Repeat the core routine.

Something like this:

Code: Select all

default questions = ["quest1","quest2"]
default quest_index = 0

label core:
    $ success = False # default to False, set to True if you'll give the correct answer
    $ thequestion = questions[quest_index] # The question label we'll process
    call expression thequestion # this call a label based on an expression
    if success:
        call correct_reply # <- This manage when an answer is correct
    else:
        call wrong_reply # <- This manage when an answer is wrong
    $ quest_index += 1 # the next question to process ...
    # probably there use a check to verify if any question left, if none jump to the end of the quiz.
    jump core

### Question example
label quest1:
    # .. the questions
    # You can call a screen with parameters (question, answers, and what they return) to abstract it.
    # call screen quiz (question="Who does it?", a1=("blabla", True), a2=("blueblue", False), a3=("globglob", False))
    # The answer return a Flag (True or False).
    $ success = _return
    return
    
Just proxy code. Anyway this should help you greatly in the debug phase.
Thanks for your time. As a result of your comment I was able to direct my attention else where and find the cause of the problem.

Some image buttons had action Return instead of action Return(). Adding in the parenthesis got rid of the problem. The problem was occurring when the mouse was hovering over image or text buttons with this issue. I don't think I used to get that error, but perhaps I only ever tested that screen on android where you can't hover or it has to do with a new version of Renpy.

Thank you for your example of lean code, I will try to take sometime to dissect it and learn from it in the near future. :)

Post Reply

Who is online

Users browsing this forum: Google [Bot]