- Jul 23, 2023
- 50
- 157
Hi All,
Working on whether or not I can create a VN. I am just running into things that don't make sense. Hoping this can be a place I ask some pretty basic questions and get some guidance on. Probably the first hiccup I am seeing is around OOP in my code. I am just working on functionality bits to ensure I can build the VN I am thinking about. I am creating an "Actor" class:
I have a pretty basic statement for it that looks like this:
This all works fine up until here:
RenPy tosses me this:
Anyone have any insight into what could be causing this? I have checked my indentation but I am using all spaces and indented as needed I think.
Working on whether or not I can create a VN. I am just running into things that don't make sense. Hoping this can be a place I ask some pretty basic questions and get some guidance on. Probably the first hiccup I am seeing is around OOP in my code. I am just working on functionality bits to ensure I can build the VN I am thinking about. I am creating an "Actor" class:
Code:
### Actor Object
init python:
class Actor:
def __init__(self, character, name, relationship, affection = 0):
self.character = character
self.name = name
self.relationship = relationship
def affectionUp(self, amount):
self.affection += amount
renpy.notify(self.name + " liked that!")
def affectionDown(self, amount):
self.affection -= amount
renpy.notify(self.name + " will remember that!")
Code:
define mel = Actor(
Character("Melissa", who_color = "#213fe9"),
"Melissa",
"Neighbor"
)
Code:
mel.character "[mc.name], do you like me?"
menu:
"Yes":
$ mel.affectionUp(1)
mel.character "Thanks!"
"No":
$ mel.affectionDown(1)
mel.character "Ouch"
Code:
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/story/intro.rpy", line 28, in script
$ mel.affectionUp(1)
File "game/story/intro.rpy", line 28, in <module>
$ mel.affectionUp(1)
AttributeError: 'Actor' object has no attribute 'affectionUp'
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/story/intro.rpy", line 28, in script
$ mel.affectionUp(1)
File "C:\Program Files\RenPy\renpy\ast.py", line 823, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "C:\Program Files\RenPy\renpy\python.py", line 1178, in py_exec_bytecode
exec(bytecode, globals, locals)
File "game/story/intro.rpy", line 28, in <module>
$ mel.affectionUp(1)
AttributeError: 'Actor' object has no attribute 'affectionUp'
Windows-10-10.0.22631 AMD64
Ren'Py 8.2.3.24061702