Onscreen buttons not working?

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
Green Skies
Regular
Posts: 53
Joined: Wed Jun 16, 2010 1:47 am
Projects: Shoot The Moon (GXB Otome)
Organization: Green Skies
Contact:

Onscreen buttons not working?

#1 Post by Green Skies » Thu Jul 01, 2010 3:29 pm

I'm having a spot of trouble with my onscreen buttons. I've used the code from http://www.renpy.org/wiki/renpy/doc/coo ... _Game_Menu, and while I'm playing through my game, the buttons only work a quarter of the time.

They're your basic Save, Skip, Load, Preferences, and also Stats buttons. The only buttons that seem to work 100% of the time are the Stats button and Skip button.

When I try the Save, Load, or Preferences buttons, the traceback says "TypeError: 'int' object is not callable". What can I do to fix this?

Thanks in advance!

*Edit* Here's the code.

Code: Select all

I'm sorry, but an exception occured while executing your Ren'Py
script.

TypeError: 'int' object is not callable

While running game code:
 - script at line 89 of /Users/msi/Desktop/realistair-mac/cafedatingsim/game/script.rpy
 - python at line 26 of renpy-6.10.2/common/00layout.rpy.
 - script at line 328 of renpy-6.10.2/common/_layout/classic_load_save.rpym

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

  File "/Users/msi/Downloads/renpy-6.10.2/renpy/bootstrap.py", line 260, in bootstrap
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/main.py", line 310, in main
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/main.py", line 93, in run
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/execution.py", line 234, in run
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/ast.py", line 1126, in execute
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/exports.py", line 378, in menu
  File "renpy-6.10.2/common/00layout.rpy", line 26, in _display_button_menu
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/exports.py", line 463, in display_menu
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/ui.py", line 70, in interact
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/display/core.py", line 1578, in interact
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/display/core.py", line 2072, in interact_core
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/display/layout.py", line 647, in event
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/display/layout.py", line 647, in event
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/display/layout.py", line 647, in event
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/display/layout.py", line 647, in event
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/display/behavior.py", line 460, in event
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/curry.py", line 38, in __call__
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/game.py", line 292, in call_in_new_context
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/execution.py", line 234, in run
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/ast.py", line 558, in execute
  File "/Users/msi/Downloads/renpy-6.10.2/renpy/python.py", line 937, in py_exec_bytecode
  File "renpy-6.10.2/common/_layout/classic_load_save.rpym", line 330, in <module>
  File "renpy-6.10.2/common/_layout/classic_load_save.rpym", line 237, in _file_picker
  File "renpy-6.10.2/common/_layout/classic_load_save.rpym", line 191, in _file_picker_file_page
TypeError: 'int' object is not callable

While running game code:
 - script at line 89 of /Users/msi/Desktop/realistair-mac/cafedatingsim/game/script.rpy
 - python at line 26 of renpy-6.10.2/common/00layout.rpy.
 - script at line 328 of renpy-6.10.2/common/_layout/classic_load_save.rpym

Ren'Py Version: Ren'Py 6.10.2e
Current Project: Shoot the Moon // Devblog

User avatar
vaanknight
Regular
Posts: 118
Joined: Sun Mar 28, 2010 6:01 pm
Completed: Happy Weird-Day! How a freckled fairy can save your world (Or get more freckles in the process...)"
Projects: Nameless 2D Fighting Game
Contact:

Re: Onscreen buttons not working?

#2 Post by vaanknight » Thu Jul 01, 2010 5:05 pm

there isn't much there to see, you need to post the code you wrote for your preferences screen, then we'll take a look :]
Image

Green Skies
Regular
Posts: 53
Joined: Wed Jun 16, 2010 1:47 am
Projects: Shoot The Moon (GXB Otome)
Organization: Green Skies
Contact:

Re: Onscreen buttons not working?

#3 Post by Green Skies » Thu Jul 01, 2010 5:43 pm

Ahh thank goodness someone wants to help ^^;

But I'm not sure what you mean by that code (kinda of a newbie at this). Do you mean this?:

Code: Select all

# This file adds a number of buttons to the lower-right hand corner of
# the screen. Three of these buttons jump to the game menu, which
# giving quick access to Load, Save, and Prefs. The fourth button
# toggles skipping, to make that more convenient.

init python:    
        
    # Give us some space on the right side of the screen.
    style.window.right_padding = 100

    def toggle_skipping():
        config.skipping = not config.skipping

    show_button_game_menu = True

    def button_game_menu():

        if show_button_game_menu:

            # to save typing
            ccinc = renpy.curried_call_in_new_context

            ui.vbox(xpos=0.99, ypos=0.98, xanchor='right', yanchor='bottom')
            ui.textbutton("Stats", clicked=ccinc("stats"), xminimum=80)
            ui.textbutton("Skip", clicked=toggle_skipping, xminimum=80)
            ui.textbutton("Save", clicked=ccinc("_game_menu_save"), xminimum=80)
            ui.textbutton("Load", clicked=ccinc("_game_menu_load"), xminimum=80)
            ui.textbutton("Prefs", clicked=ccinc("_game_menu_preferences"), xminimum=80)
            ui.close()


    config.overlay_functions.append(button_game_menu)

label stats:
    scene statsbg
    python:
        
        ui.hbox()
        
        # Column 1
        ui.vbox()
        # Title 1
        ui.text("STATS")
        # Culinary Skill
        ui.text("Culinary Skill: %d"%cul_skill)
        # Work Ethic
        ui.text("Work Ethic: %d"%w_e)
        # Intelligence
        ui.text("Intelligence: %d"%intel)
        # Creativity
        ui.text("Creativity: %d"%cre)
        # Social
        ui.text("Social: %d"%soc)
        ui.close()
        
        ui.close()
        
        ui.textbutton("Go Back", clicked=ui.returns("goback"), ypos=0.9, xpos=0.5)
        
    $ picked = ui.interact()
    if picked == "goback":
        return


    config.overlay_functions.append(button_game_menu)


The first code is copied from a tutorial and modified to make a stats button only, and the code beneath it is my stats screen.
I thought what the on-screen buttons did was just redirect to the same screens you get from the main menu (which work fine from the main menu).
Current Project: Shoot the Moon // Devblog

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Onscreen buttons not working?

#4 Post by Aleema » Thu Jul 01, 2010 10:05 pm

The problem is likely with how you're choosing to display your stats. What are the values of "cul_skill", "w_e", etc? If any of them are strings (words in quotes), then this will break the script. There are two different types of infomation, strings and integers, or text and numbers. To display numbers you do what you did ("%d" % variable), but to show strings you can just put a + sign and then the variable name.

Code: Select all

ui.text("Culinary Skill: "+cul_skill)
Alternatively, you can do what you did with the integers, just use the call sign %s instead of %d.

If cul_skill is indeed a number, then ignore me. =P

Green Skies
Regular
Posts: 53
Joined: Wed Jun 16, 2010 1:47 am
Projects: Shoot The Moon (GXB Otome)
Organization: Green Skies
Contact:

Re: Onscreen buttons not working?

#5 Post by Green Skies » Fri Jul 02, 2010 2:11 am

Aaah that might be it! Thanks, Aleema. :) I'll have to try to fix it when I get the time. My game program is on the computer without internet lol

And btw, I absolutely adore your RockRobin demo. I want to be the first to play it when it officially comes out <3
Current Project: Shoot the Moon // Devblog

User avatar
Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: Onscreen buttons not working?

#6 Post by Jake » Fri Jul 02, 2010 9:05 am

Aleema wrote:The problem is likely with how you're choosing to display your stats. What are the values of "cul_skill", "w_e", etc? If any of them are strings (words in quotes), then this will break the script.
While it's true that a string interpolated as a number would break the game, there's no way it would break it with an "int object is not callable" exception. That comes when you try and treat an integer as a function, e.g.:

Code: Select all

  58()
(You would get 'int parameter expected' or something along those lines instead if the string interpolation was the problem.)

The most likely cause for this is that there's somewhere where a function is expected as a parameter to a method and an int has been passed in by accident. Or maybe a configuration variable which is supposed to be a function has been set with an int, or something like that.

To start with, ignore your stats code; it's nothing to do with that at all. It works fine, there's no reason it should affect the save/load functionality.

Instead, could you:
- Show us what's on line 89 of script.rpy, which Ren'Py thinks is involved with your error
- Let us know if you're trying to modify the file picker for save/load at all (since some of the stack trace you posted for your error involve that) and show us the code if you are.
- Check whether you're setting any config variables which aren't mentioned by default in options.rpy? If so, again: let us know what they are, show us the code.




EDIT: Forgot to ask: are you aware that you're including the line:

Code: Select all

    config.overlay_functions.append(button_game_menu)
twice? That's unnecessary, you should only call it once. Unless it's a copy-and-paste error from when you copied the code to the forum?
Server error: user 'Jake' not found

Post Reply

Who is online

Users browsing this forum: Bing [Bot]