Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
- Posts: 12
- Joined: Thu Jun 20, 2019 6:47 pm
I'm trying to code an inventory:
Code: Select all
default banana_item = Consumable("banana", 10, 10)
def __init__(self, hunger, athletic, haggling, gaming, tolerance, charisma, logic, mmusic, cooking):
self.hunger = hunger
self.max_hunger = hunger
def addHunger(self, amount):
self.hunger += amount
if self.hunger > self.max_hunger:
self.hunger = self.max_hunger
def __init__(self, img, value):
self.img = img
self.value = value
def __init__(self, img, value, hunger_gain):
InventoryItem.__init__(self, img, value)
self.hunger_gain = hunger_gain
def consumeEdible(self, target):
selected_item = None
When I play through it, the game opens fine, but when I open the inventory I get the error: TypeError: 'tuple' object is not callable
Does anyone have any advice on how to fix this? Am I coding the items wrong??
- Posts: 239
- Joined: Thu Aug 31, 2017 11:47 am
It seems you tried to call a tuple as if it was a function, but I don't see anything in the code you posted that could be a tuple.
I don't see your definition of theinventory variable, but if you defined it like a tuple, maybe with default inventory = (), then it should be a list, default inventory = . Tuples aren't changeable so they don't have an append method.
Also, in the consumeEdible method, you should put the global selected_item statement before changing the variable value, else it won't be changed correctly.
The most important words a man can say are, “I will do better.”
Users browsing this forum: No registered users