Help with a class

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
HiddenLife
Newbie
Posts: 13
Joined: Wed Sep 09, 2020 8:10 pm
Contact:

Help with a class

#1 Post by HiddenLife » Mon Dec 21, 2020 4:06 am

Hi everyone, this is my code.

Code: Select all

        class Item:
            def __init__(self, name, cost, count):
                self.name = name
                self.cost = cost
            def pcount (self, number):
                self.count += number
            def mcount (self, number):
                self.count -= number
I want that item.pcount increase "count" of one given item.
But I know almost nothing about programming in phyton, so what I written did not work. Anyone know how to fix that?
Thank you.

philat
Eileen-Class Veteran
Posts: 1853
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Help with a class

#2 Post by philat » Mon Dec 21, 2020 4:14 am

You don't have a self.count = count in the __init__().

Post Reply

Who is online

Users browsing this forum: mold.FF