Page 1 of 1

adding a saving "notes" txt box in a game

PostPosted: Sun Dec 30, 2007 7:27 pm
by Zehper48
is there a way you can make a txt number where you can write in it, and below it theres a save button and load button. is there a way when you type somthing, and hit save it saves that txt, and when you click load it loads the txt you saved?

Re: adding a saving "notes" txt box in a game

PostPosted: Tue Jan 01, 2008 9:57 pm
by Sgt. Sparky
I will help you as soon as I get back (4-5 hours or less.)

Re: adding a saving "notes" txt box in a game

PostPosted: Wed Jan 02, 2008 2:12 am
by Sgt. Sparky
sombody who has the nick name of Zehper48 recently wrote:is there a way you can make a txt number where you can write in it, and below it theres a save button and load button. is there a way when you type somthing, and hit save it saves that txt, and when you click load it loads the txt you saved?


:D
Yes:
1. Create an actor called "tactor".
2. Configure the input the way you want.
2.1. (if you don't know how to configure the input.) Bring up the actor control for your text actor and click on the text button
near the upper right part of your actor control window.
After you have done this another little window should pop up.
Select your font and your font size and colour (and weither you want it to be soft or not.)
Now click on Okay. The window where you selcect your font will go away. Now type in the text you want to appear
as your default text actors text. (If you want it for making notes just make it a | and 254 spaces after that. (255 characters is the maximum for copying text.)
Now click on the input button to the bottom left of that window. Now set it up (this part is easy to figure out) the way you want it.
Now for the coding part! :D

3. Create an actor called "save".
4. Create an actor called "load".
5. Add the save and load button images for the save and load actors.
6. Put this code on the mouse button down event of save:

Code: Select all
FILE*file;
file = fopen("TextNote.txt", "w+");
fwrite(&tactor.text, sizeof(tactor.text), 1, file);
fclose(file);


7. put this code on the mouse button down event of load:

Code: Select all
FILE*file;
char tdoc[255];
file = fopen("TextNote.txt", "r+");
fread(&tdoc, sizeof(tdoc), 1, file);
fclose(file);
strcpy(tactor.text, tdoc);


8. Save your game then you are done. :D

If you want a more advanced version (with many more things,)
please let me know and I will make a demo. :D

Re: adding a saving "notes" txt box in a game

PostPosted: Wed Jan 02, 2008 9:27 am
by Zehper48
thanks for helping me!, but theres a problem
when i hit save, it make a .txt file in my game directory, but its blank even though i put in text, when i i click load, the text box shrinks and theres no text =( what happend?

Re: adding a saving "notes" txt box in a game

PostPosted: Wed Jan 02, 2008 6:51 pm
by Sgt. Sparky
Zehper48 wrote:thanks for helping me!, but theres a problem
when i hit save, it make a .txt file in my game directory, but its blank even though i put in text, when i i click load, the text box shrinks and theres no text =( what happend?


:oops: Oops, my bad.
Put "r+" instead of "w+" on the load buttons mouse button down event where the fopen("TextNote.txt", "w+"); is.

Re: adding a saving "notes" txt box in a game

PostPosted: Wed Jan 02, 2008 7:47 pm
by Zehper48
WOW! thank you it really reallly super worked! you own man! THX so much Sgt. Sparky

Re: adding a saving "notes" txt box in a game

PostPosted: Wed Jan 02, 2008 9:47 pm
by Sgt. Sparky
You are welcome. :D