forums

TNT Basic Forums > Programming Q&A
Saving, RPG etc.
< Last Thread     Next Thread >
Author
Thread        Post A Reply

04-18-2004 11:36

Posted by:
Carl PokéthulhuMasta

Location:
Norway

Click Here to Email Carl PokéthulhuMasta   Find more posts by Carl PokéthulhuMasta

Hi!
I'm back! Less annoying and with better english (I hope).

So I just started working on my first big project. It's called Pokéthulhu and is kind of a clone of pokemon, except it's going to have different monsters, locations, story, combat system and more. But one big question has got me a little stuck, there is going to be tons of variables, and I just want a save option that saves all the variables and where in the code they've gotten. If I'm going to write down all the variables for the monsters, and one in theory should be able to catch as many monsters as one would like and store training information about each of them, it's not possible. (At least time consuming.)
So is there some way to use the file commands that I've missed?

04-18-2004 15:39

Posted by:
kemalyun

Location:
Frankfurt/Germany

Find more posts by kemalyun

Saving

If you have a lot of values about monsters stored, you shouldn't use different variables for that. You should use arrays instead. Doing so, you can save the content of the array with a simple FOR-NEXT loop.

04-18-2004 15:46

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Hmm...RPG huh? My only advise would be to plan out the game well before you try to make it. Then you won't run into all the problems I have :(

Well, about saving, you should listen to kemalYun and use arrays. Then you could have an array like:
int buddyData[maxBuddies,4]

Then each guy would have 4 places in the array, for stats and such.

04-18-2004 15:48

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Oh, and about the infinite monsters...
It might be easier to set a limit at some excessively large number like 1000, but if you're stuck on making it up to the player, then you can use arrays; just increase the size of the array with the dimension command.

04-18-2004 16:34

Posted by:
Carl PokéthulhuMasta

Location:
Norway

Click Here to Email Carl PokéthulhuMasta   Find more posts by Carl PokéthulhuMasta

Thanks guys!

Thanks!
I think I know what arrays are, but this question was really about saving... Do I really have to write all the variables that is to be saved?

04-18-2004 17:51

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Yeah. There's no way to just record all variables. You have to specifically write to a file.

But it's not so bad with arrays. You could do something like this:

int j
for j=0 to maxBuddies-1
for stat=0 to 4
file write int buddyStats[j,stat]
next stat
next j

04-20-2004 12:11

Posted by:
Carl PokéthulhuMasta

Location:
Norway

Click Here to Email Carl PokéthulhuMasta   Find more posts by Carl PokéthulhuMasta

Working on saving

Okay, I've written a saving code but it's totally wrong.
I don't get what they're saying in the help place and there are no examples.
That would be kind of cool.

well here's the code: can you tell me what's wrong?




' set directory user preferences 'where do save files go
'if file exists ("Pokethulhu save files:main")
'0=open file
'0(":Pokethulhu save files:main",true,save,data)
'else
'new folder("Pokethulhu save files")
'0=create file
'("main",save,data)
'end if

' if erase=0 and gamenr=1 and pressed (36) and file exists ("Pokethulhu save files:game1")
' 1=open file (":Pokethulhu save files:game1",true,save,data)
' chosengame=true
' if else erase=0 and gamenr=1 and pressed (36)
' 1=create file ("game1",save,data)
' chosengame=true
' if else erase=0 and gamenr=2 and pressed (36) and file exists ("Pokethulhu save files:game2")
' 2=open file ("game2",true,save,data)
' chosengame=true
' if else erase=0 and gamenr=2 and pressed (36)
' 2=create file("game2",save,data)
' chosengame=true
' if else erase=0 and gamenr=2 and pressed (36) and file exists ("Pokethulhu save files:game3")
' 3=open file ("game3",true,save,data)
' chosengame=true
' if else erase=0 and gamenr=3 and pressed (36)
' 3=create file ("game3",save,data)
' chosengame=true
' end if

04-20-2004 13:52

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Well, for one thing, you use a variable to store the open file data, not a zero.

int saveVar=10
int FILE=open file(...)
close file FILE
int FILE=ask create file(...)
file write FILE,saveVar

And so on.

Another thing is that your code says "if else" but it should say "else if."

04-20-2004 18:49

Posted by:
Carl PokéthulhuMasta

Location:
Norway

Click Here to Email Carl PokéthulhuMasta   Find more posts by Carl PokéthulhuMasta

Thank you very much! But it didn't take me to long to get stusk again. I've played around alot with it to try to solve it, but for no good.
I get this error:

*** Runtime exception caught ***
Line# : 112
Code : main=open file (":Pokethulhusavefiles:main",true,"save","data")
Error : Could not open file.

First I thought it was because the file was already open, but no. Now I'm getting serious doubts that it's being created at all. maybe there's something wrong with my "file exists"?

set directory user preferences

if file exists ("Pokethulhusavefiles:main") = false
new folder("Pokethulhusavefiles")
main=create file("main","save","data")
close file main
end if

main=open file ("Pokethulhusavefiles:main",true,"save","data")

I don't think it's the ":"'s but I'm not sure :-(

04-28-2004 20:50

Posted by:
Wil Hostman

Find more posts by Wil Hostman

I've found that, on my machine, (OSX) I can't use pathnames in filenames.

so... set your directory using the directory commands in TNT, and only use one level hierarchies... and no paths in the filenames sections.

I don't know if it is a bug...

04-29-2004 15:32

Posted by:
philipp

Location:
Switzerland

Click Here to Email philipp   Find more posts by philipp

hi,
it should work if you put a ":" to the beginnig of the path:

set directory user preferences
main=open file(":pokethulhusavefiles:main",true,"save","data")


regards,
philipp

04-29-2004 15:59

Posted by:
philipp

Location:
Switzerland

Click Here to Email philipp   Find more posts by philipp

hi,
sorry I've forgotten one thing:

set directory user preferences
if file exists ("Pokethulhusavefiles:main") = false
new folder("Pokethulhusavefiles")
main=create file("main","save","data")
close file main
end if

'this saves the file into the preferences folder

set directory user preferences
if file exists ("Pokethulhusavefiles:main") = false
new folder("Pokethulhusavefiles")
main=create file(":pokethulhusavefiles:main","save","data")
close file main
end if

'this saves the file into the pokethulhusavefiles folder

then it should work

Philipp

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.