Beginner can't figure out Inventory system error

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
twistedrose1011
Newbie
Posts: 3
Joined: Wed Jan 22, 2020 6:25 pm
Contact:

Beginner can't figure out Inventory system error

#1 Post by twistedrose1011 » Sun Feb 02, 2020 10:34 am

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
Attachments
script.rpy
(1.2 KiB) Downloaded 7 times

User avatar
RicharDann
Veteran
Posts: 264
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: Beginner can't figure out Inventory system error

#2 Post by RicharDann » 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)
The most important step is always the next one.

twistedrose1011
Newbie
Posts: 3
Joined: Wed Jan 22, 2020 6:25 pm
Contact:

Re: Beginner can't figure out Inventory system error

#3 Post by twistedrose1011 » Sun Feb 02, 2020 11:46 am

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.

Post Reply

Who is online

Users browsing this forum: No registered users