Page 1 of 1

Beginner can't figure out Inventory system error

Posted: Sun Feb 02, 2020 10:34 am
by twistedrose1011
I recently learned Renpy and started messing around with inventory systems using these posts as reference. ( I tried copying the first link as a test)
viewtopic.php?f=8&t=50136&p=496516&hili ... on#p496516
viewtopic.php?f=8&t=30788
viewtopic.php?f=51&t=44730#p458992

I can't seem to figure out why I keep getting this error, I feel like I forgot something very simple. If you don't mind explaining what I did wrong and how to fix it.
I was trying to create an inventory that shows an image button when clicked shows the description of the item for the player.
Any other tips with an inventory involving imagebuttons will also help.

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 45, in script
    call screen inventory
  File "renpy/common/000statements.rpy", line 531, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
  File "game/script.rpy", line 11, in execute
    screen inventory():
  File "game/script.rpy", line 11, in execute
    screen inventory():
  File "game/script.rpy", line 30, in execute
    frame:
  File "game/script.rpy", line 34, in execute
    vbox:
  File "game/script.rpy", line 35, in execute
    if selected_item:
  File "game/script.rpy", line 36, in execute
    text selected_item.desc
AttributeError: 'unicode' object has no attribute 'desc'

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

Full traceback:
  File "game/script.rpy", line 45, in script
    call screen inventory
  File "D:\Downloads 2\renpy-7.3.5-sdk\renpy\ast.py", line 1949, in execute
    self.call("execute")
  File "D:\Downloads 2\renpy-7.3.5-sdk\renpy\ast.py", line 1937, in call
    return renpy.statements.call(method, parsed, *args, **kwargs)
  File "D:\Downloads 2\renpy-7.3.5-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 "D:\Downloads 2\renpy-7.3.5-sdk\renpy\exports.py", line 2905, in call_screen
    rv = renpy.ui.interact(mouse="screen", type="screen", roll_forward=roll_forward)
  File "D:\Downloads 2\renpy-7.3.5-sdk\renpy\ui.py", line 297, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "D:\Downloads 2\renpy-7.3.5-sdk\renpy\display\core.py", line 2702, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "D:\Downloads 2\renpy-7.3.5-sdk\renpy\display\core.py", line 3094, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "D:\Downloads 2\renpy-7.3.5-sdk\renpy\display\core.py", line 541, in visit_all
    d.visit_all(callback, seen)
  File "D:\Downloads 2\renpy-7.3.5-sdk\renpy\display\core.py", line 541, in visit_all
    d.visit_all(callback, seen)
  File "D:\Downloads 2\renpy-7.3.5-sdk\renpy\display\core.py", line 541, in visit_all
    d.visit_all(callback, seen)
  File "D:\Downloads 2\renpy-7.3.5-sdk\renpy\display\screen.py", line 430, in visit_all
    callback(self)
  File "D:\Downloads 2\renpy-7.3.5-sdk\renpy\display\core.py", line 3094, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "D:\Downloads 2\renpy-7.3.5-sdk\renpy\display\screen.py", line 440, in per_interact
    self.update()
  File "D:\Downloads 2\renpy-7.3.5-sdk\renpy\display\screen.py", line 625, in update
    self.screen.function(**self.scope)
  File "game/script.rpy", line 11, in execute
    screen inventory():
  File "game/script.rpy", line 11, in execute
    screen inventory():
  File "game/script.rpy", line 30, in execute
    frame:
  File "game/script.rpy", line 34, in execute
    vbox:
  File "game/script.rpy", line 35, in execute
    if selected_item:
  File "game/script.rpy", line 36, in execute
    text selected_item.desc
  File "<screen language>", line 36, in <module>
AttributeError: 'unicode' object has no attribute 'desc'

Windows-8-6.2.9200
Ren'Py 7.3.5.606
tryinventory3 1.0
Sun Feb 02 09:23:40 2020

Re: Beginner can't figure out Inventory system error

Posted: Sun Feb 02, 2020 11:41 am
by RicharDann
In this line:

Code: Select all

$ inventory_list.append("burger")
You're appending the string "burger" to the inventory, which is the unicode object the error is talking about.
You need to append the burger object itself:

Code: Select all

$ inventory_list.append(burger)

Re: Beginner can't figure out Inventory system error

Posted: Sun Feb 02, 2020 11:46 am
by twistedrose1011
RicharDann wrote: Sun Feb 02, 2020 11:41 am In this line:

Code: Select all

$ inventory_list.append("burger")
You're appending the string "burger" to the inventory, which is the unicode object the error is talking about.
You need to append the burger object itself:

Code: Select all

$ inventory_list.append(burger)
omg thank you so much.