Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, Grant, Neb), 908 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Level Change & Saving Data? #278709
07/15/09 10:20
07/15/09 10:20
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline OP
Member
Roxas  Offline OP
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Hey there

I just coded a simple level changing system which works actually realy fine to me but now i was wondering how to store up data which changed in a level.

Imagine a RPG. you're in a big city and you go into a house (another map is loaded for that house) and then you get a quest "find 10 herbs".
now you leave the house, the city is reloaded (level change again) now you go and find 10 herbs.
now once you return to that house the guy who said "hey dude go and collect 10 herbs" would say "hey dude collect 10 herbs for me!" and even worse the 10 herbs are gone oO.

now my questsion is:

how is it possible to store such data between level changes? another script? temporary variables? a text file where i could read and write in the data? what is the best way to store data for a whole rpg like nums of potions, equipment, key items, character stats etc.?

hope you can help me

cheers.
Roxas~

Re: Level Change & Saving Data? [Re: Roxas] #278717
07/15/09 10:39
07/15/09 10:39
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
If you use game_save?
or file_var_write and than at the level start file_var_read! Hope that helps!

Re: Level Change & Saving Data? [Re: Rei_Ayanami] #278723
07/15/09 11:06
07/15/09 11:06
Joined: Feb 2009
Posts: 2,154
Damocles_ Offline
Expert
Damocles_  Offline
Expert

Joined: Feb 2009
Posts: 2,154
You need to use global variables/arrays or
temporary function variables that dont have a my pointer
(just set my pointer to null)

All other functions (with an attached entity) will get stopped/deleted in a levelchange.

Anything that should be persistant when exiting/restartig the game
should be saved to a file (the fileoperations, writing variables to a textfile for example) or for
beginners with that game_save command. (it much easier, but then
you have less control about what is beeing saved)


More important than saving the data, is to restore a level-state.
So each actor / object in a level should check
in its action at startup (new level loaded), what relevant changes must be
adjusted for.

Re: Level Change & Saving Data? [Re: Damocles_] #278761
07/15/09 13:31
07/15/09 13:31
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline OP
Member
Roxas  Offline OP
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
thanks for your replies
I think Ill use something like the file_var_write and file_var_read commands.

I wrote 2 functions, one stores data, one restores the data. the data will be written in a temp.txt file, and everytime i'll change the map they'll be updated. so there is no possiblity to do some cheating with this file.

well but thats one hell of a work to store all the variables into that file, but well i think its worth it.

thank you for your fast replies again.

best wishes~
Roxas

Re: Level Change & Saving Data? [Re: Roxas] #278768
07/15/09 14:23
07/15/09 14:23
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
If you write the functions the right way, with many parameters, this shouldn't be all that hard.
For example, I'd write my function something like this:
void saveQuestStatus(int questNumber, int levelNumber, int questStatus)


and then write another function which retreaves exactly that data from the file:
void loadQuestStatus(int questNumber, int levelNumber)

that should make the level switching much more comfortable.


~"I never let school interfere with my education"~
-Mark Twain
Re: Level Change & Saving Data? [Re: Roxas] #278806
07/15/09 17:08
07/15/09 17:08
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline OP
Member
Roxas  Offline OP
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
well I've got a lot more to save then just 3 variables. ^^

Code:
function store_data()
{
	data = file_open_write("temp");
	
	file_var_write(data, npc001.talked_to);
	file_var_write(data, npc002.talked_to);

	file_close(data);
}

function restore_data()
{
	data = file_open_read("temp");
	
	npc001.talked_to = file_var_read(data);
	npc002.talked_to = file_var_read(data);
	
	file_close(data);
}



thats how it looks like,
and i wanted to add every variable that is needed for the level change, such as hp, mp, items etc.

works fine for me though.

but i wonder how to save the game, if i would save the whole game like this everyone could just save the game and change the values for example potions: 10000 o rsomething.

is there a way to encrypt the file or something?

cheers
Roxas

Re: Level Change & Saving Data? [Re: Roxas] #278813
07/15/09 17:20
07/15/09 17:20
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
You can save you´re whole game with game_save and load it with game_load
bye
Rei_Ayanami

Re: Level Change & Saving Data? [Re: Rei_Ayanami] #278985
07/16/09 10:41
07/16/09 10:41
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline OP
Member
Roxas  Offline OP
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
yeah I know that, but the problem is, when I save the game like that and load it with the game_load command my character runs 2 times faster than before, the animations speed up aswell, thats strange and i don't have a clue why that happens.

any suggestions?

cheers
Roxas

Re: Level Change & Saving Data? [Re: Roxas] #278989
07/16/09 10:49
07/16/09 10:49
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
If you load a new level, terminate the actions from the Player. I think one function (that with the movement Code) is calling twice after the level_load and so you caracter runs 2 times faster...

Re: Level Change & Saving Data? [Re: Widi] #278997
07/16/09 10:58
07/16/09 10:58
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline OP
Member
Roxas  Offline OP
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
the level change works fine ^^

I meant saving the game. close the engine, rerun the engine and load the save_state via game_load. then the character seams to call his own action two times.

when i change levels I freeze the whole game. load a new level and unfreeze it. between the freeze and unfreeze I save and restore game data which is important for the gameflow via a temp file and my functions i posted earlier.

now I made a savepoint like in games like Final Fantasy. you approach it and save your game.

when i load the game the character appears on the position where i saved the game and all works fine, except of the characters animations, movement and gravity. its all doubled

so i use for saving temporary data the file_var... commands
and for saving the whole game i wanted to use game_save and game_load, and those two game commands r messing up

cheers
Roxas

Last edited by Roxas; 07/16/09 10:59.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1