adding a saving "notes" txt box in a game

Non-platform specific questions.

adding a saving "notes" txt box in a game

Postby Zehper48 » Sun Dec 30, 2007 7:27 pm

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?
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

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

Postby Sgt. Sparky » Tue Jan 01, 2008 9:57 pm

I will help you as soon as I get back (4-5 hours or less.)
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

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

Postby Sgt. Sparky » Wed Jan 02, 2008 2:12 am

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
Last edited by Sgt. Sparky on Wed Jan 02, 2008 6:49 pm, edited 1 time in total.
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

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

Postby Zehper48 » Wed Jan 02, 2008 9:27 am

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?
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

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

Postby Sgt. Sparky » Wed Jan 02, 2008 6:51 pm

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.
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

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

Postby Zehper48 » Wed Jan 02, 2008 7:47 pm

WOW! thank you it really reallly super worked! you own man! THX so much Sgt. Sparky
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

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

Postby Sgt. Sparky » Wed Jan 02, 2008 9:47 pm

You are welcome. :D
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron