Noob python question for pros

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
Jezzy
Regular
Posts: 30
Joined: Wed Jun 21, 2017 2:18 pm
Contact:

Noob python question for pros

#1 Post by Jezzy » Fri Jul 07, 2017 10:48 pm

Hello again!

I'm trying to build a refrigerator inventory system based on the inventory example from this forum but theres something I'm not getting with arrays in python. I'm pretty sure I dont understand how to parse an array. Bellow is my code I think its related between this :

$ sorted_foods = sorted(refrigerator.foods, key=attrgetter('name'), reverse=False)

and this :

for foods in sorted_foods:

But I dont see why...

I know my object is working and I can add items to it (I tried with a if(pizza in refrigerator.foods) in a menu and it works). I have an item in my refrigerator object but still, this code is not working.

Thank you for your time!
Last edited by Jezzy on Sat Jul 08, 2017 4:28 pm, edited 2 times in total.

User avatar
Milkymalk
Miko-Class Veteran
Posts: 752
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Noob python question for pros

#2 Post by Milkymalk » Fri Jul 07, 2017 11:44 pm

What exactly is not working? Do you get an error message, or just misbehavior? What is happening when you run it?
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

Jezzy
Regular
Posts: 30
Joined: Wed Jun 21, 2017 2:18 pm
Contact:

Re: Noob python question for pros

#3 Post by Jezzy » Fri Jul 07, 2017 11:49 pm

I'm sorry I should have been more specific indeed.

No image are showned in the boxes. There is no error message, everything "seem" to be working as intented.

However...

Normally, I should see an icon of a pizza slice (the image is existing in my gui/ folder) with a counter on it (10/10) which represent the number of "charges" the item have before getting removed from the refrigerator object.

The tooltip should be shown in the blue bar on roll over the item... normally.
Attachments
empty fridge.jpg

User avatar
Milkymalk
Miko-Class Veteran
Posts: 752
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Noob python question for pros

#4 Post by Milkymalk » Sat Jul 08, 2017 12:02 am

You do some fancy voodoo for getting the x and y of the pic. What happens if you drop it and just use fixed coordinates for the imagebutton? Is anything displayed at all? This is to check if you somehow messed that part up, in which case the images could be far off the screen.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

Jezzy
Regular
Posts: 30
Joined: Wed Jun 21, 2017 2:18 pm
Contact:

Re: Noob python question for pros

#5 Post by Jezzy » Sat Jul 08, 2017 12:05 am

Milkymalk wrote:You do some fancy voodoo for getting the x and y of the pic. What happens if you drop it and just use fixed coordinates for the imagebutton? Is anything displayed at all? This is to check if you somehow messed that part up, in which case the images could be far off the screen.
MEGA FACEPALM...

Thank you very much! I should go get some sleep lol!

My image was just outside of the viewport... somewhere

Thanks again!

User avatar
Milkymalk
Miko-Class Veteran
Posts: 752
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Noob python question for pros

#6 Post by Milkymalk » Sat Jul 08, 2017 12:08 am

Glad I could help :)

Don't worry, it probably happened to everyone who ever tried to make a dynamic screen. Your code looked right, so having wrong coordinates was my best guess.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

Jezzy
Regular
Posts: 30
Joined: Wed Jun 21, 2017 2:18 pm
Contact:

Re: Noob python question for pros

#7 Post by Jezzy » Sat Jul 08, 2017 1:22 pm

*deleted. It was a typo*

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]