Here is the code that I am using to add items to an 'inventory'. It is a fixed length of 35 (the array):
Dim inventory(35) As InventoryItem
The code for InventoryItem is as follows:
Public Class InventoryItem Public Shared amount As Integer Public Shared type As String Public Property Amnt() As Integer Get Return amount End Get Set(ByVal value As Integer) amount = value End Set End Property Public Property ItemType() As String Get Return type End Get Set(ByVal value As String) type = value End Set End Property End Class
All I wanted it to be was just a container. Things seem better in classes.
Here is where my issue lies. When I break a 'block' it runs a subprocedure called AddToInventory:
Sub addToInventory(ByVal type As String) Debug.Write(type) If Not type = "air" Then For i As Integer = 0 To inventory.Count - 1 If inventory(i).ItemType = "" Then inventory(i).ItemType = type inventory(i).Amnt += 1 Exit For ElseIf inventory(i).ItemType = type And inventory(i).Amnt < 64 Then inventory(i).Amnt += 1 Debug.WriteLine(inventory(i).ItemType & inventory(i).Amnt & " , " & i) Exit For End If Next End If End Sub
The issue with this code is: when I break a block, it adds to the inventory fine. But afterwards, only blocks of that type will add to the inventory. Nothing else will. I'll add some sample output:
stonestonestone2 , 0 stonestone3 , 0 stonestone4 , 0 stonestone5 , 0 stonestone6 , 0 dirtdirt
Hopefully someone can help.
Thanks and regards