Noob python question for pros
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.
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.
Noob python question for pros
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!
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.
- 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
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)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
Re: Noob python question for pros
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.
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.
- 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
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)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
Re: Noob python question for pros
MEGA FACEPALM...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.
Thank you very much! I should go get some sleep lol!
My image was just outside of the viewport... somewhere
Thanks again!
- 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
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.
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)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
Re: Noob python question for pros
*deleted. It was a typo*
Who is online
Users browsing this forum: Bing [Bot], Google [Bot]