Recoil Posted July 6, 2015 Share Posted July 6, 2015 This is the way an items stats are currently saved: For i = 0 To Stats.StatCount - 1   FilePutObject(F, Item(itemNum).AddStat(i)) Next I am trying set this up to to convert to xml: For i = 0 To Stats.StatCount - 1   itemData.AddStat(i) = Item(itemNum).AddStat(i) next This is throwing a null exception and I'm not sure how to set this to work. I already have my serializer/deserializer set to handle the stuff that needs to be saved. Link to comment Share on other sites More sharing options...
jcsnider Posted July 6, 2015 Share Posted July 6, 2015 You either never instantiated itemData OR you never declared the bounds of the itemData.AddStat() array. We would need to see how these objects are created in order to help further. Link to comment Share on other sites More sharing options...
Recoil Posted July 6, 2015 Author Share Posted July 6, 2015 Okay, here is everything for the SaveItem sub. First is how it is currently done in the engine: Dim filename As String     Dim F As Long     filename = Application.StartupPath & "\DataFiles\items\item" & itemNum & ".dat"     F = FreeFile()     FileOpen(F, filename, OpenMode.Binary, OpenAccess.Write, OpenShare.Default)     FilePutObject(F, Item(itemNum).Name)     FilePutObject(F, Item(itemNum).Pic)     FilePutObject(F, Item(itemNum).Type)     FilePutObject(F, Item(itemNum).Data1)     FilePutObject(F, Item(itemNum).Data2)     FilePutObject(F, Item(itemNum).Data3)     FilePutObject(F, Item(itemNum).ClassReq)     FilePutObject(F, Item(itemNum).AccessReq)     FilePutObject(F, Item(itemNum).LevelReq)     FilePutObject(F, Item(itemNum).Mastery)     FilePutObject(F, Item(itemNum).Price)     For i = 0 To Stats.StatCount - 1       FilePutObject(F, Item(itemNum).AddStat(i))     Next     FilePutObject(F, Item(itemNum).Rarity)     FilePutObject(F, Item(itemNum).Speed)     FilePutObject(F, Item(itemNum).Handed)     FilePutObject(F, Item(itemNum).BindType)     For i = 0 To Stats.StatCount - 1       FilePutObject(F, Item(itemNum).StatReq(i))     Next     FilePutObject(F, Item(itemNum).Animation)     FilePutObject(F, Item(itemNum).Paperdoll)     FilePutObject(F, Item(itemNum).Stackable)     FileClose(F) Now, I am wanting to change that section to use my serializer: Dim itemData As Types.ItemRec = New Types.ItemRec     itemData.Name = Item(itemNum).Name     itemData.Pic = Item(itemNum).Pic     itemData.Type = Item(itemNum).Type     itemData.Data1 = Item(itemNum).Data1     itemData.Data2 = Item(itemNum).Data2     itemData.Data3 = Item(itemNum).Data3     itemData.ClassReq = Item(itemNum).ClassReq     itemData.AccessReq = Item(itemNum).AccessReq     itemData.LevelReq = Item(itemNum).LevelReq     itemData.Mastery = Item(itemNum).Mastery     itemData.Price = Item(itemNum).Price     For i = 0 To Stats.StatCount - 1       itemData.AddStat(i) = Item(itemNum).AddStat(i)     Next     itemData.Rarity = Item(itemNum).Rarity     itemData.Speed = Item(itemNum).Speed     itemData.Handed = Item(itemNum).Handed     itemData.BindType = Item(itemNum).BindType     For i = 0 To Stats.StatCount - 1       itemData.StatReq(i) = Item(itemNum).StatReq(i)     Next     itemData.Animation = Item(itemNum).Animation     itemData.Paperdoll = Item(itemNum).Paperdoll     itemData.Stackable = Item(itemNum).Stackable     Dim filePath As String = Application.StartupPath & "\DataFiles\items\item" & itemNum & ".ori"     ModObjectSerializer.SerializeObject(filePath, itemData) When it hits the first For loop it comes up with the error. Until it hits that everything else is going fine from what I can tell. Since I deleted all of my items there is nothing in the folder. I'm also changing the extension from .dat to .ori so that eventually I can assign these to open in an external editor. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now