Code: Select all
init python:
class Object:
def __init__(self, path, target, xp, yp):
self.path = path
self.target = target
self.xp = xp
self.yp = yp
class Room:
def __init__(self):
self.objects = {}
def reveal(self, object):
self.objects[object] = object
return True
def show_objects(self):
for object in self.objects:
ui.imagebutton(object.path, object.path, clicked=renpy.jump(object.target), xalign=object.xp, yalign=object.yp)
def clear(self):
Fade(.5)
self.objects.clear()
#Variables
room = Room()
#The objects themselves
wardrobe = Object("obj/wardrobe.png", "wardrobe", 0.3, 0.4)
def build_room(room):
room = rm
#Clear and create new scene
renpy.scene()
renpy.show("bg " + room)
show_objects(room)
Fade(.5)
Code: Select all
label north:
$ room.clear
$ objects.reveal(wardrobe)
$ build_room("north")
jump navigation
Just as I start the game, I get the following error:
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/build_room.rpy", line 43, in script
$ room.clear
File "game/build_room.rpy", line 43, in python
$ room.clear
AttributeError: 'str' object has no attribute 'clear'
I also get that I could be entirely wrong with all the code, but as I can't get past the initial error relating to the 'clear' function, I can't test it. I know the build_room function works, but little else. If anyone sees any obvious problems with my entire line of thinking then I'd also appreciate you telling me that.