Using typeof() on a nested table returns nil

In the code below I have created a table of type “Room”, whose attributes are the rooms position, and a table containing the adjacent rooms. The adjacent rooms are tables themselves, however when I try to print the type of the adjacent rooms, it returns “nil” when it should return “table”. This means that I am unable to access attributes in the adjacent room. What am I doing wrong and how can I fix this? Thanks in advance.

2 Likes

That’s most likely due to PartyRoom1 having a nil value.

You are sending ShowRoom before assigning it a value, making it nil. Consider setting ShowRoom before MainStage.

Thanks for the reply. This worked initially, however it creates a new problem. I have arranged the adjacent rooms such that all of the rooms are adjacent to at least one different room, and they form a ring formation (“ShowRoom” is adjacent to a chain of rooms that ends up being adjacent to “ShowRoom” again). Is there a different way to go about this?
image_2024-02-14_152925906

You can send an empty table to the function, then change the door’s adjrooms to the doors you want.

1 Like

It works now. Thanks for your help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.