I want to create a list of items in each room of a text adventure game, but I want each item to have both the name of the item, and the description of the item, so I can call either/both strings for the item depending on what I need the item for.
Dim StartRoom As RoomInfo
Public Class Items
Public ItemName As String
Public ItemDescription As String
End Class
Public Structure RoomInfo
Dim RoomName As String
Dim BasicDescription As String
Dim RoomDescription As String
Dim ValidExists As List(Of String)
Dim ObjectsInRoom As List(Of String)
Dim ItemsInRoom As List(Of Items)
End Structure
Sub InitializeRooms()
StartRoom.RoomName = "Start Room"
StartRoom.RoomDescription = "Test Description"
StartRoom.BasicDescription = "Test Basic Description"
Dim TestItem As New Items With {
.ItemName = "Test Item",
.ItemDescription = "This is a Test Item"
}
StartRoom.ItemsInRoom.Add(TestItem)
End Sub
I've created a list, ItemsInRoom, which is a list of Items, a Class. This way, each room can have a unique list of items that can be changed as the player picks up or interacts with them. That's what the Initialize Rooms sub is for- I can run it when the game loads, and set up all the information for each room in the game. Anyway, when I try to add the TestItem to the list, I get an 'Object reference not set to an instance of an object.' error. I'm extremely dumb and this is probably the most obvious error in the book, but I can't find the solution to this particular case. Thanks for the help.