Game Development Community

Save character data help

by Jason Holm · in Torque Game Engine · 06/19/2006 (1:59 pm) · 1 replies

Hello, I am very new with this and I'm trying to simply make it so you can make a custom character and save it. I would also like the all the saved characters to appear on a list (I need to get the save part working first!).

In my "MakeCharGui" file, I have a guitexteditctrl to enter the name, which works fine.

new GuiTextEditCtrl() {
Profile = "GuiTextEditProfile";
HorizSizing = "relative";
VertSizing = "relative";
position = "75 81";
Extent = "90 12";
MinExtent = "8 2";
Visible = "1";
Variable = "pref::Player::Name";
maxLength = "255";
historySize = "0";
password = "0";
tabComplete = "0";
sinkAllKeyEvents = "0";
password = "0";
passwordMask = "*";
};

Then I have a button to save the character.

new GuiBitmapButtonCtrl(save_char) {
Profile = "GuiDefaultProfile";
HorizSizing = "relative";
VertSizing = "relative";
position = "80 92";
Extent = "140 30";
MinExtent = "8 2";
command= "savechar();";
Visible = "1";
text = "Save Character";
groupNum = "-1";
buttonType = "PushButton";
};

I have this function to make the file (which I made from using other posts).

function savechar()
{

%name = pref::Player::Name;
%file = "./chars/" @ %name @ ".cs";
%exp = "$" @ %name @ "Stats::*";
export(%exp, %file, false);
}

It doesnt make a file for the character. Also, what exactly does the "false" and "%exp" doing? mean If anyone could give me some detailed help I would greatly appreciate it! (I'm very noob! =p). Oh, and is there a way to to make a custom look for the GuiTextEditCtrl, instead of just a white box? Or at least change the color for it? Thanks.

#1
06/19/2006 (3:04 pm)
%result = Export("$Pref::Game::*", "./game/prefs.cs", False);

Quote:
Saves the values of variables starting with search to the file named filename. When append is set to true, the file is appended; when set to false, the file is overwritten. The search string supports "*" to match any number of any characters and "?" to match any single character.

The first variable seems to be the search string. it will search for all global variables that match the search string such at "$BobStats::*", so i guess that all global variables starting with that will be saved to the file.

The true and fales if for append(true), and ovewrite(false)

Perhaps you should check the console after exporting, to see if any error messages where displayed.