Invalid access to property or key 'room_exists' on a base object of type 'PanelContainer (Room)'

Godot Version

Godot 4.3

Question

I’m working on a text-based adventure game and for the script for my rooms I’m trying to create a function that creates exists between the rooms but I’m getting the error shown in the title. Not sure what could be causing this so any guidance would be grateful. Here is my code for the script for reference:

extends PanelContainer

class_name Room

@export_multiline var room_name: String
@export_multiline var room_description: String
@export var room_exits: Dictionary = {}

#connects the exits in the four cardinal directions
func con_exit_wesn(d: String, r):
match d:
“west”:
#create an entry for this direction in this room’s exists
#and connect it to our new room
room_exits[d] = r

		#in the new room's exists connect the opposite direction 
		#to the first room
		r.room_exists["east"] = self
	"east":
		room_exits[d] = r
		r.room_exists["west"] = self
	"north":
		room_exits[d] = r
		r.room_exists["south"] = self
	"south":
		room_exits[d] = r
		r.room_exists["north"] = self
	_:
		print("Invalid Connection")

Maybe you mean to use room_exits instead of room_exists? Are you supplying the same Room class to the argument r?

1 Like

Yup that was it I just didn’t notice I spelled exits wrong. I really appreciate the help