Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Calling String from custom .dat file.


jsorr2
 Share

Recommended Posts

Trying to call Monster's name from file. Come's up with a blank. What am I doing wrong?

```

Sub SaveMonsters()

Dim i As Long

For i = 1 To MAX_MONSTERS

Call SaveMonster(i)

Next

End Sub

Sub SaveMonster(ByVal MonstersNum As Long)

Dim filename As String

Dim F As Long

filename = App.path & "\data\Monsters\Monsters" & MonstersNum & ".dat"

F = FreeFile

Open filename For Binary As #F

Put #F, , Monsters(MonstersNum)

Close #F

End Sub

Sub LoadMonsters()

Dim filename As String

Dim i As Long

Dim F As Long

Call CheckMonsters

For i = 1 To MAX_MONSTERS

filename = App.path & "\data\BaseMonster" & ".txt"

F = FreeFile

Open filename For Binary As #F

Get #F, , Monsters(i)

Close #F

Next

End Sub

Sub CheckMonsters()

Dim i As Long

For i = 1 To MAX_MONSTERS

If Not FileExist("\Data\Monsters\Monsters" & i & ".dat") Then

Call SaveMonsters(i)

End If

Next

End Sub

Sub ClearMonster(ByVal index As Long)

Call ZeroMemory(ByVal VarPtr(Monsters(index)), LenB(Monsters(index)))

Monsters(index).MonstersName = vbNullString

End Sub

Sub ClearMonsters()

Dim i As Long

For i = 1 To MAX_MONSTERS

Call ClearMonster(i)

Next

End Sub

```
```

Public Function GetFileName(ID As Long) As String

GetFileName = App.path & "\data\Monsters\Monsters" & ID & ".dat"

End Function

Public Function GetMonstersName(ID As Long) As String

Dim filename As String

If ID > 0 And ID <= 50 Then

filename = GetFileName(ID)

GetMonstersName = GetVar(filename, CStr(ID), "Name")

Else

GetMonstersName = OutBounds

End If

End Function

```
Link to comment
Share on other sites

Use

```

open filename for binary as #F

input,,monster(index)

close #f

```
i wrote it out of memory so the input statement might be wrong.

For the name, after loading all you monster use

```

GetMonsterName = Monster(index).Name

```
Or something. Again you will have to edit it to work properly.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...