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.
def remove_shirt (self, shirt):
if shirt in self.equipped_shirt:
for shirt in self.equipped_shirt:
self.equipped_shirt.remove(shirt)
This function says that it needs at least 2 arguments. I don't need a second argument, so could you please tell me is there another way I can write this function, without having this problem.
It's a method (of a class), not a function. When method is bound to a class, "self" refers to an instance of a class. There is nothing about this in documentation, this is pure python.
As I've said in previous post, your code looks like a mess
Do you care what kind of shirt is equipped? If so, you need to pass an argument when removing the shirt. If you don't and just want to have an empty list, why the heck do you have a "shirt" as a second argument when removing it?
You problem seems to be neither with Ren'Py nor with Python, more likely it's your own design. You previous "I have reasons" reply doesn't cut it because there is no reason for bad code, especially not in simple systems like inventories.
Actually there is a reason.. For someone that started coding not long ago, and is doing his project just to practice, it's not so easy to know every possible way things work. I'm trying to come up with my own ways how to make something work, instead of copying other people's code.
You shouldn't simply copy people's code and you definitely shouldn't try stuff until it somehow works.
You have to underestand what you're doing.
Look at code from others and try to figure out what each bit does, then go ahead and try using what you learned.
You previous method would work if you simply remove the "shirt" parameter.
Fair enough, but other people put in a lot of thought and time into designs that wish to share, not learning from that is more often a mistake that it is not.
Bartulisica wrote:Could you tell me how would you remove everything from the list, and add just one thing with a single imagebutton.