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

[EO] Player Notes


Beanie93
 Share

Recommended Posts

This is my first tutorial for Eclipse Origins.
When you have completed this tutorial, you will have a working Player Notes system, which will save text into a text file, and read it back into a textbox.

You will use the FileSystemObject object for doing this. Let's get on the tutorial.

First of all, all of this is done Client-side. Once you got your client project loaded, go to the 'Project' menu, and at the bottom, click on 'References'. Then, look for 'Microsoft Scripting Runtime' and check it.

Alright, what we just did is let VB6 have access to the FileSystemObject object. Let's start on the actual tutorial.

All edits are done in frmMain.

Make:
1 PictureBox - picNotes
1 TextBox - txtNotes
2 Buttons - cmdSave and cmdClose

Make sure the PictureBox is on top of everything, then move onto the Menu (where picParty, picInventory, etc. is). Make sure the txtNotes, cmdSave and cmdClose are in it.

Arrange your txtNotes, cmdSave and cmdClose at your liking.
Then, create a Label named lblNotes. Place it on picOptions, or wherever you want.

Now, let's get onto the code.
Go at the top of frmMain's code, and below **Private PresentX As Long**, add:
```
'FileSystemObject
Dim FSO As FileSystemObject
Dim TS As TextStream
```
Then, double-click cmdClose, and add the following:
```
picNotes.Visible = False
txtNotes.Text = ""
```
After that's done, double-click cmdSave, and add the following:
```
    Dim Text As String

    Text = txtNotes.Text
    Set FSO = New FileSystemObject

      Set TS = FSO.OpenTextFile(App.Path & "\data files\notes.txt", ForWriting, True)
      TS.WriteLine Text
      TS.Close
```
What we just did, is declare a string variable for our txtNotes, and then look for notes.txt in data files, which we will add later. Then, it writes whatever the user has written in the txtNotes. Then, it closes it so you can open the file again later.

Now, we are almost done.
Double-click lblNotes and add the following:
```
  Set FSO = New FileSystemObject
    If FSO.FileExists(App.Path & "\data files\notes.txt") Then
        Set TS = FSO.OpenTextFile(App.Path & "\data files\notes.txt")

        Do While Not TS.AtEndOfStream
            txtNotes.Text = TS.ReadLine
        Loop
        TS.Close
    End If
  picNotes.Visible = True
```
This also looks for notes.txt in data files, and then sets the text notes.txt contains to txtNotes. We close it and make picNotes display.

Finally, go to your data files folder, and create a text file named 'notes.txt'.
There you go, a working Player Notes system with no bugs.

Of course, you are free to use this in your game, as long as you give credit to me and do not claim it as your own.

I have tested it, and found no bugs, but in case you find one, make sure to report it to me in this thread, or via PM. Hope this helps you in your project.

Regards,
Beanie93
Link to comment
Share on other sites

Make sure it's at top of everything. Right-click it, and click "Bring to front".
If that doesn't work, make sure picNotes is above the other pics, like picParty, picOptions, picSkills, etc.

If you have what I just said done, just make sure that it got this code:
```
  Set FSO = New FileSystemObject
    If FSO.FileExists(App.Path & "\data files\notes.txt") Then
        Set TS = FSO.OpenTextFile(App.Path & "\data files\notes.txt")

        Do While Not TS.AtEndOfStream
            txtNotes.Text = TS.ReadLine
        Loop
        TS.Close
    End If
  picNotes.Visible = True
```
Link to comment
Share on other sites

  • 9 months later...
Sorry about the bumps but srsly im not used to EO source im used to EE only just starting to get used to it but come on i spent a hour trying to figure it out but it has a error
with

Dim FSO As FileSystemObject

the FSO As FileSystemObject is errord
Link to comment
Share on other sites

You seem to have forgotten to do this part:

> First of all, all of this is done Client-side. Once you got your client project loaded, go to the 'Project' menu, and at the bottom, click on 'References'. Then, look for 'Microsoft Scripting Runtime' and check it.

Please don't blindly copy/paste things without reading into how it works. Or at the very least read the tutorial 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...