Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

3 Dimensional Chat / how can I save my game?

Author
Message
seweete
20
Years of Service
User Offline
Joined: 15th May 2003
Location:
Posted: 19th May 2003 15:17
I've tryed this for a loooong time!!
but I cant figure out an easy way to do it.
I can "make file 'save.sav'"
but that does not make any sence, does it?
I mean It only makes an empty file with nothing in it!!

I was woundering:
how can I make my game understand that when I press 'S' I want to save the game as it is in the moment i press it. and make a file named "save.sav"?
It would be really really REALLY usefull if I could learn this.
Becouse I cant find a tutorial that explains this.

I guess someone outhere can save their games. and I would be really glad if someone told me how they do it.

please help me!!
wait... I think I just... no, cant be... wait...
yes I think... maybe... Yes!! I GOT AN IDEA!!
Shadow
21
Years of Service
User Offline
Joined: 17th Oct 2002
Location: In the shadows
Posted: 19th May 2003 16:12
It's simple. Look up the commands like 'write byte' for saving and 'read byte' for loading. Then all you've got to do is decide which variables need saving and kabam! you're there.
seweete
20
Years of Service
User Offline
Joined: 15th May 2003
Location:
Posted: 19th May 2003 17:16
but, if I use 'write byte' does it make a file that I can open later, with 'read byte'? :-s

Can u give me an example?

wait... I think I just... no, cant be... wait...
yes I think... maybe... Yes!! I GOT AN IDEA!!
sicjoshsic
21
Years of Service
User Offline
Joined: 8th May 2003
Location: United Kingdom
Posted: 19th May 2003 21:15 Edited at: 19th May 2003 21:17
ok, im going to use loads of variables instead of actual numbers here, so you can change it easy. this example i will save health,x position,y position, z position

i should mention that where you read from the file, it isn't reading what you tell it to (ie read byte 1,health# DOESN'T read the value for health)
each time you read, it reads a new line, so you MUST read them back the same way you saved them, the variable is just where it stores the data

there are better/faster ways of doing this ie arrays, but i don't bother with them (more options this way)

[EDIT]
by the way, if you try and write to a file that already exists, it won't work. to fix that just change the code to this:


seweete
20
Years of Service
User Offline
Joined: 15th May 2003
Location:
Posted: 20th May 2003 12:02
ok.. So if i write



it will make a new file '2' and write all data to that file?
how many of these files can I make?? unlimited?

hm if that is all, then It is REALLY easy to save and load.. hehe
I must try it out as soon as I get Home from school..

wait... I think I just... no, cant be... wait...
yes I think... maybe... Yes!! I GOT AN IDEA!!
Kensupen
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: United States
Posted: 20th May 2003 14:20
If you are using DBPro, just use Save Array and Load Array. It's what I do for all my save games, and it's almost instantaneous. But, if you don't. you have to do it the old fashioned way above. TIP: delete the file and re-create it when you go to save. I think when you open to write, it appends data, not replace.

-Kensupen
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 20th May 2003 14:47
I know in classic if you try to write a file that already exists using "Write to file" you get a big ol happy "That file already exists" error

RPGamer

Current Project: Eternal Destiny
Questions? Comments? Suggestions? Go to the Eternal Destiny Forum!
sicjoshsic
21
Years of Service
User Offline
Joined: 8th May 2003
Location: United Kingdom
Posted: 20th May 2003 16:43
seweete: your almost write, except it will be called save2.save
you can make as many as you like, the second number just tells db which file its looking at when you go write byte, read byte etc.
i think the second number has to be less then 6000 and something, but if you close the file (like you did in your snippet) then you can re-use that number again

seweete
20
Years of Service
User Offline
Joined: 15th May 2003
Location:
Posted: 20th May 2003 22:35
Ehhh.. I don't think I quite understand... :-s

I tryed it on one of my games, and I wrote what 'sicjoshsic' wrote:
(sort of)



but Nothing happens!!

it justs make the file "save.sav" and writes those things into it,
but when I press L for Load, nothing happens, the player just stands where it stood, and the life goes to 0!!

what's wrong?

wait... I think I just... no, cant be... wait...
yes I think... maybe... Yes!! I GOT AN IDEA!!
sicjoshsic
21
Years of Service
User Offline
Joined: 8th May 2003
Location: United Kingdom
Posted: 21st May 2003 18:37
if you like i can send you a set of file handling functions ive made. they are:
get_number(source file,tag)
get_string(source file,tag)
edit_value(source file,tag,value)

more information in a readme i send with them, also an example. tell me if you want it and i'll email it you

Login to post a reply

Server time is: 2024-05-09 10:12:59
Your offset time is: 2024-05-09 10:12:59