saving text/variables

Talk about making games.

saving text/variables

Postby Oman » Wed Apr 23, 2008 12:16 am

Hello friends,

I am programming a game, and have a need to set the text (which the user has inputed) to a variable in order to save it (with saveVars).
I already know how to save vars, and how to be able to make the text be inputed , but the question is, how do i set the text to a var.

i figured it would be something like...

char pname;
pname = p_name.text;
saveVars (etc.. etc.. etc..);

but obviously it doesnt work...

can someone help?
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

Re: saving text/variables

Postby Oman » Wed Apr 23, 2008 1:30 am

ok, here is waht ive done so far...

i created a variable called pname in the variables tab.. it is a string, and it is an actor variable.

my code is

Code: Select all
pname = p_name.text;


and thats it... so now, how come it has to be a actor variable...?

uh oh... i cant save an actor variable... so, now what do i do?!?!!?
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

Re: saving text/variables

Postby pyrometal » Wed Apr 23, 2008 1:35 am

Ummm... It doesn't need to be an actor variable for sure. But I'm not sure I get where you're problem is exactly... Are you trying to save a string or save your file with a "user inputed" name?
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: saving text/variables

Postby Oman » Wed Apr 23, 2008 1:39 am

a little of both...

In this part of my game, the user inputs his/her name, and then presses enter. when they press enter i want it to save (and be able to load) the text (saves on enter, loads on creation of the next game).

the semi-problem comes with my complete lack of coding knowledge when talking about text/strings and stuff...

so, if u could give me both codes i would love it (and give u a major point)! :D
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

Re: saving text/variables

Postby pyrometal » Wed Apr 23, 2008 2:06 am

I'll make a demo!
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: saving text/variables

Postby Oman » Wed Apr 23, 2008 2:19 am

thanks so much, ill eagerly be awaiting it! :)
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

Re: saving text/variables

Postby pyrometal » Wed Apr 23, 2008 2:39 am

Here it is! (Not that it crashes if you try to load a non-existant file).

Saving strings.zip
A demo
(194.74 KiB) Downloaded 127 times
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: saving text/variables

Postby Oman » Wed Apr 23, 2008 12:15 pm

WOW thats great, +1 for you. :D

now, i would be even more impressed if you could show me how to make a list of all the save games i have so far, and then be able to click on one of them to load it. Is that possible with GE.

something like...

(click to load)

[Save Game1]
[Save Game2]
[Save Game3]
[Save Game4]
etc...
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

Re: saving text/variables

Postby pyrometal » Wed Apr 23, 2008 2:59 pm

I can only do that with predetermined file names... If the file names are different and your asking me to make a program that search for them, then I do not know how... Sorry
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: saving text/variables

Postby Oman » Wed Apr 23, 2008 9:59 pm

actually i never really needed the file names to be changeable, so it would be fine if they would be like

[save1]
[save2]
[save3]

and only three would be fine
:)
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

Re: saving text/variables

Postby pyrometal » Wed Apr 23, 2008 11:44 pm

Heres what you asked for!

Save_text demo 2.zip
3 files!
(195.95 KiB) Downloaded 131 times
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: saving text/variables

Postby Oman » Thu Apr 24, 2008 12:34 am

Dude, That is absolutely Wonderful! +1 to u!!!! thanks, thats all i can think of for now, but when i need more help ill be back :D
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

Re: saving text/variables

Postby pyrometal » Thu Apr 24, 2008 1:05 am

np, anytime!
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron