Game Development Community

Save & Load system?- HELP

by Alias Leung · in Technical Issues · 05/27/2008 (2:13 am) · 4 replies

HI! i get some problem when i develop my rpg game in Save & Load system.

When i use the new ScriptObject method to save my character attribute such as life
/*

new ScriptObject(PlayerData)
{
Health = $life;
};

/*

And then i attach the following code in my save and load button

function MainMenuGui::save( %this )
{
PlayData.save("AdventureKit/gameScripts/File.txt");
echo("savegame");
}

function MainMenuGui::load( %this )
{
exec("AdventureKit/gameScripts/File.cs");
echo("loadgame");
echo($life);
}

/*

When i running the game there is no error, but i still can't load the file data. WHY?

About the author

Recent Threads


#1
05/27/2008 (6:49 am)
You're saving into File.txt and try to load from File.cs - that won't work :)

Oh and try something like that to print the data:
function MainMenuGui::load( %this )
{
exec("AdventureKit/gameScripts/File.cs");
echo("loadgame");
echo([b]PlayerData.Health[/b]);
}
#2
05/27/2008 (9:33 pm)
Thank for you answering!

i try the code that you have provide

function MainMenuGui::load( %this )
{
exec("AdventureKit/gameScripts/File.cs");
echo("loadgame");
echo(PlayerData.Health);
}

i can see the life is same of the health by checking the[ echo(PlayerData.Health); ]

but how to apply the life value to my character while my character life is load by [ $life=%this.life; ]
#3
05/27/2008 (10:57 pm)
Try yourPlayerObject.setEnergyLevel(PlayerData.Health).
#4
05/28/2008 (5:10 pm)
I noticed that in your save function you have

function MainMenuGui::save( %this )
{
PlayData.save("AdventureKit/gameScripts/File.txt");
echo("savegame");
}

shouldn't it be:

function MainMenuGui::save( %this )
{
PlayerData.save("AdventureKit/gameScripts/File.txt");
echo("savegame");
}