Page 1 of 1

saving text/variables

PostPosted: Wed Apr 23, 2008 12:16 am
by Oman
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?

Re: saving text/variables

PostPosted: Wed Apr 23, 2008 1:30 am
by Oman
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?!?!!?

Re: saving text/variables

PostPosted: Wed Apr 23, 2008 1:35 am
by pyrometal
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?

Re: saving text/variables

PostPosted: Wed Apr 23, 2008 1:39 am
by Oman
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

Re: saving text/variables

PostPosted: Wed Apr 23, 2008 2:06 am
by pyrometal
I'll make a demo!

Re: saving text/variables

PostPosted: Wed Apr 23, 2008 2:19 am
by Oman
thanks so much, ill eagerly be awaiting it! :)

Re: saving text/variables

PostPosted: Wed Apr 23, 2008 2:39 am
by pyrometal
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

Re: saving text/variables

PostPosted: Wed Apr 23, 2008 12:15 pm
by Oman
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...

Re: saving text/variables

PostPosted: Wed Apr 23, 2008 2:59 pm
by pyrometal
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

Re: saving text/variables

PostPosted: Wed Apr 23, 2008 9:59 pm
by Oman
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
:)

Re: saving text/variables

PostPosted: Wed Apr 23, 2008 11:44 pm
by pyrometal
Heres what you asked for!

Save_text demo 2.zip
3 files!
(195.95 KiB) Downloaded 131 times

Re: saving text/variables

PostPosted: Thu Apr 24, 2008 12:34 am
by Oman
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

Re: saving text/variables

PostPosted: Thu Apr 24, 2008 1:05 am
by pyrometal
np, anytime!