I would like to reference different room objects before they have been added to a table so that all objects are kind of interconnected.
Roblox will not allow me to do so and I was wondering if there was a way/work around that any of you have come up with.
Here is my code right now:
local Room = require(script.Room)
local Rooms = {}
Rooms.emptyRoom = Room.new(game.ReplicatedStorage.Rooms.EmptyRoom, {["left"] = {Rooms.roomWallLeft, Rooms.roomWallFront, Rooms.roomWallBack}, ["right"] = {Rooms.roomWallRight, Rooms.roomWallFront, Rooms.roomWallBack}, ["front"] = {Rooms.roomWallLeft, Rooms.roomWallRight, Rooms.roomWallBack}, ["back"] = {Rooms.roomWallLeft, Rooms.roomWallFront, Rooms.roomWallRight}})
Rooms.roomWallLeft = Room.new(game.ReplicatedStorage.Rooms.RoomWallLeft, {["left"] = nil, ["right"] = {Rooms.roomWallRight, Rooms.roomWallFront, Rooms.roomWallBack}, ["front"] = {Rooms.roomWallLeft, Rooms.roomWallRight, Rooms.roomWallBack}, ["back"] = {Rooms.roomWallLeft, Rooms.roomWallFront, Rooms.roomWallRight}})
Rooms.roomWallRight = Room.new(game.ReplicatedStorage.Rooms.RoomWallRight, {["left"] = {Rooms.roomWallLeft, Rooms.roomWallFront, Rooms.roomWallBack}, ["right"] = nil, ["front"] = {Rooms.roomWallLeft, Rooms.roomWallRight, Rooms.roomWallBack}, ["back"] = {Rooms.roomWallLeft, Rooms.roomWallFront, Rooms.roomWallRight}})
Rooms.roomWallFront = Room.new(game.ReplicatedStorage.Rooms.RoomWallFront, {["left"] = {Rooms.roomWallLeft, Rooms.roomWallFront, Rooms.roomWallBack}, ["right"] = {Rooms.roomWallRight, Rooms.roomWallFront, Rooms.roomWallBack}, ["front"] = nil, ["back"] = {Rooms.roomWallLeft, Rooms.roomWallFront, Rooms.roomWallRight}})
Rooms.roomWallBack = Room.new(game.ReplicatedStorage.Rooms.RoomWallBack, {["left"] = {Rooms.roomWallLeft, Rooms.roomWallFront, Rooms.roomWallBack}, ["right"] = {Rooms.roomWallRight, Rooms.roomWallFront, Rooms.roomWallBack}, ["front"] = {Rooms.roomWallLeft, Rooms.roomWallRight, Rooms.roomWallBack}, ["back"] = nil})
return Rooms
The room is a pseudo class using a module script since luau doesn’t provide classes normally.