Error unicode non callable object with screen [HELP]

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
Zimon
Newbie
Posts: 3
Joined: Sun Mar 22, 2020 7:19 am
Contact:

Error unicode non callable object with screen [HELP]

#1 Post by Zimon »

Hello guys, I tried to create three different inventory style menus that load when you start the game, the problem is that one of them, although the code is similar, does not want to work, giving me these errors

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 7, in script call
    call prepare_all from _call_prepare_all
  File "game/global.rpy", line 28, in script call
    call prepare_powers from _call_prepare_powers
  File "game/powers.rpy", line 21, in script
    python:
  File "game/powers.rpy", line 23, in <module>
    power_6 = Power("Power 6", image="gui/powers/power_6.png")
TypeError: 'unicode' object is not callable

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

Full traceback:
  File "game/script.rpy", line 7, in script call
    call prepare_all from _call_prepare_all
  File "game/global.rpy", line 28, in script call
    call prepare_powers from _call_prepare_powers
  File "game/powers.rpy", line 21, in script
    python:
  File "C:\Users\Infin\Desktop\Champion-v0.06-pc\renpy\ast.py", line 914, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\Infin\Desktop\Champion-v0.06-pc\renpy\python.py", line 2028, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/powers.rpy", line 23, in <module>
    power_6 = Power("Power 6", image="gui/powers/power_6.png")
TypeError: 'unicode' object is not callable

Windows-8-6.2.9200
Ren'Py 7.3.5.606
 v0.05
Sun Mar 22 12:36:04 2020

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 14, in script call
    call prepare_all from _call_prepare_all_1
  File "game/global.rpy", line 28, in script call
    call prepare_powers from _call_prepare_powers
  File "game/powers.rpy", line 21, in script
    python:
  File "game/powers.rpy", line 23, in <module>
    power_6 = Power("Power 6", image="gui/powers/power_6.png")
TypeError: 'unicode' object is not callable

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

Full traceback:
  File "game/script.rpy", line 14, in script call
    call prepare_all from _call_prepare_all_1
  File "game/global.rpy", line 28, in script call
    call prepare_powers from _call_prepare_powers
  File "game/powers.rpy", line 21, in script
    python:
  File "C:\Users\Infin\Desktop\Champion-v0.06-pc\renpy\ast.py", line 914, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\Infin\Desktop\Champion-v0.06-pc\renpy\python.py", line 2028, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/powers.rpy", line 23, in <module>
    power_6 = Power("Power 6", image="gui/powers/power_6.png")
TypeError: 'unicode' object is not callable

Windows-8-6.2.9200
Ren'Py 7.3.5.606
 v0.05
Sun Mar 22 12:43:41 2020
As a result, when I try to add an object to the menu it is said that it is not defined, despite the fact that in the other menus the objects are added without problems and are all defined in the same way.
I just can't figure out what the problem is, in case of doubt I'll even leave you the code.

The menu that doesn't work :

Code: Select all

label prepare_powers:

    python:

        power_6 = Power("Power 6", image="gui/powers/power_6.png")


    return

init -1:
    transform power_eff: ## Hover over Powers to make them brighter
        zoom 0.6
        xalign 0.26
        yalign 0.30
        alpha 0.7
        on idle:
            linear 0.2 alpha 0.7
        on hover:
            linear 0.2 alpha 1.0

    image tooltip_power_1=LiveComposite((1080, 50), (10,0), Text("| {color=f89898}ENERGY SPHERE{/color} | \n An energy sphere, useful in every situation.", style="tips_bottom"))

init -1 python:
    from operator import attrgetter  ## Required for sorting items

    power_page = 0  ## Power screen start page
    power_item = None
    selecting_power = False
    power_selection_canceled = False

    class Power(store.object):
        def __init__(self, name, image="", cost=0):
            self.name = name
            self.image=image  ## Image file to use for this item
            self.cost=cost  ## How much does it cost in shops? (IRRELEVANT FOR POWERS)
        def use(self):  ## here we define what should happen when we use the item
            self.name = self.name

    class Powers(store.object):
        def __init__(self, money=10):
            self.money = money
            self.powers = []
        def add(self, power):
            self.powers.append(power)
        def drop(self, power):
            if power in self.powers:
                self.powers.remove(power)
            foundpower = power
            for index, currentitem in enumerate(self.powers):
                if currentitem.name == power.name:
                    foundpower = currentitem
            if not foundpower == power:
                self.powers.remove(foundpower)


    def power_use():
        power_item.use()

    ## Tooltips:
    style.tips_top = Style(style.default)
    style.tips_top.size=18
    style.tips_top.color="fff"
    style.tips_top.outlines=[(3, "000000", 0,0)]
    style.tips_top.kerning = 5

    style.tips_bottom = Style(style.tips_top)
    style.tips_top.size=18
    style.tips_bottom.outlines=[(0, "000000", 1, 1), (0, "000000", 2, 2)]
    style.tips_bottom.kerning = 2

    style.button.yminimum=52
    style.button.xminimum=52
    style.button_text.color="000"
The script:

Code: Select all

init offset = -1

init python:
    config.automatic_images = [' ', '_', '/']
    config.automatic_images_strip = ['images']

## Prepare the Powers / Leads / Inventory
label prepare_all:
    call prepare_powers from _call_prepare_powers
    call prepare_leads from _call_prepare_leads
    call prepare_inventory from _call_prepare_inventory
    return

define save_version = 0.1

label after_load:
    $ loaded_game = True

    if _in_replay:
        $ renpy.block_rollback()
        return

    call prepare_all from _call_prepare_all_2

Code: Select all

label start:

    call prepare_all from _call_prepare_all

    python:
        powers = Powers()
        leads = Leads()
        inventory = Items()

    call prepare_all from _call_prepare_all_1

    $ quick_menu = False

    jump prologue_begin


    while end_game == False:
        ##"Back in the Main loop"
        call progression_next_action from _call_progression_next_action_3

    label end_game_label:
        # This ends the game.
        return
I repeat, the Leads / Inventory menus have a similar code and work without problem, it may be a stupid mistake, but I'm not finding a solution at the moment.

Post Reply

Who is online

Users browsing this forum: Ocelot