Here is my new code:
Code: Select all
init python :
inventory = Inventory()
label start:
e "You have %(inventory.money)s $" #You have 50$
$ inventory.earn(5)
e "You earn 5 $"
e "You have %(inventory.money)s $" #You have 55$
So his money is growing 55, 60, 65, 70$, etc.
When I was using global variables, I didn't have this kind of problem.
Here is the inventory class source code:
Code: Select all
class Inventory(store.object):
##############################
def __init__(self, money = 50):
self.money = money
self.items = []
## Player earn money
def earn(self, money): # Player earn money
self.money += money
PS : I read this topic, so I tried to add the below code, but it changed nothing:
Code: Select all
import renpy.store as store
import renpy.exports as renpy # we need this so Ren'Py properly handles rollback with classes