An Exeption Has Occured - An Unknown Inventory Problem

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
taraAprilDraws
Newbie
Posts: 2
Joined: Sun Aug 12, 2018 11:03 am
Contact:

An Exeption Has Occured - An Unknown Inventory Problem

#1 Post by taraAprilDraws »

I'm trying to make a point and click using Renpy, using screens and image buttons but im having some issues with the inventory. It says I need to define inventory but I'm not exactly sure how to go about it and i haven't had much luck figuring it out. Here are the screenshots of the error message and the line of code that's gone wrong.

I used two different tutorials, one for the imagebutton, pointing and clicking stuff and one for the inventory stuff. The person who made the point and click tutorial recommended the tutorial I used for the inventory. I did modify the code for the point and click to better suit my game, but i left the inventory code alone only changing <8 to the <2 you see in th screenshots. Both come up with the same error so i know this isn't the problem.

If you need to see more of the code please let me know. Also if I'm in the wrong forum it would be appreciated if I could be pointed in the right direction.

Thank you for your time.
Attachments
125.PNG
Capture.PNG

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: An Exeption Has Occured - An Unknown Inventory Problem

#2 Post by Per K Grok »

taraAprilDraws wrote: Sun Aug 12, 2018 11:33 am I'm trying to make a point and click using Renpy, using screens and image buttons but im having some issues with the inventory. It says I need to define inventory but I'm not exactly sure how to go about it and i haven't had much luck figuring it out. Here are the screenshots of the error message and the line of code that's gone wrong.

I used two different tutorials, one for the imagebutton, pointing and clicking stuff and one for the inventory stuff. The person who made the point and click tutorial recommended the tutorial I used for the inventory. I did modify the code for the point and click to better suit my game, but i left the inventory code alone only changing <8 to the <2 you see in th screenshots. Both come up with the same error so i know this isn't the problem.

If you need to see more of the code please let me know. Also if I'm in the wrong forum it would be appreciated if I could be pointed in the right direction.

Thank you for your time.
You could try putting in

$ inventory = []

after label start.

That should give you an empty inventory.

I'm just finishing up a point and click game with an inventory

viewtopic.php?f=45&t=51339
viewtopic.php?f=43&t=50760


User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: An Exeption Has Occured - An Unknown Inventory Problem

#3 Post by trooper6 »

It is current best practices to declare your variables using default outside of any block rather than using init python, or a python $ line inside the start label.

So:

Code: Select all

default inventory = []

label start:
    "Your game..."
is the current best practice.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
taraAprilDraws
Newbie
Posts: 2
Joined: Sun Aug 12, 2018 11:03 am
Contact:

Re: An Exeption Has Occured - An Unknown Inventory Problem

#4 Post by taraAprilDraws »

Hi, thanks for your help and apologies for the late reply. When I try both of these methods it no longer comes up with the error message, but it wont let me click start to try it out.

I tried shuffling around the code and whatnot to see if that was the problem but it wielded no results. Am I supposed to put something inside the square brackets?

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: An Exeption Has Occured - An Unknown Inventory Problem

#5 Post by Per K Grok »

taraAprilDraws wrote: Mon Aug 13, 2018 1:52 am Hi, thanks for your help and apologies for the late reply. When I try both of these methods it no longer comes up with the error message, but it wont let me click start to try it out.

I tried shuffling around the code and whatnot to see if that was the problem but it wielded no results. Am I supposed to put something inside the square brackets?
'inventory' in the code is a list. The part in the code where the error shows up is when the program is ordered to check if the list 'inventory' holds less than 2 items.
if len(inventory )<2:

At that point the program goes "inventory? What is that? Never heard of it."

default inventory = []
(or $ inventory= [])
creates an empty list by the name inventory. With that established the program should when ordered to check the length of the list, see that there is such a list and that it holds 0 items.

You could put something inside the brackets
i.e.
default inventory = ["money.png"]

you now have a list that contain one item, a string with the name of an image
This should not make any difference for the working of the checking of the length of the list.

The problem you now have might be a different problem unrelated to the defining of the list.

When you say that the program "wont let [you] click start to try it out" do you mean that when you click the start button on the main menu the program does not start? Nothing happens?

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: An Exeption Has Occured - An Unknown Inventory Problem

#6 Post by Imperf3kt »

Using $ inventory = [] is bad practise and should never be done. This only creates the inventory after a player presses "start".

Now imagine they save and exit.
Tomorrow, they return and press 'load'. Lo and behold, they never go past start label, "inventory" is never defined and when next interacted with, Ren'Py goes "inventory, whats that? Never heard of it"
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Post Reply

Who is online

Users browsing this forum: No registered users