Game Development Community

Help with the preferences

by Gioacchino Nigrelli · in Torque Game Engine · 08/03/2005 (7:07 am) · 12 replies

Hi guyz, I've a problem with the preferences, I'll explain better:

I made a window in which you can select the car (it's a racing game, yes) and all this things are maded by script, so I have a single file named SelectCar.gui, now I want to memorize the car you selected in pref.cs located in fps\client or common\client

I really have no idea in which mode I can do this, yes I've seek inside the others files of the game, like the gui in which you can choose the mission and insert your name and it's saved in pref.cs, but the approach is really different in this gui.

Any help?

THX to all

#1
08/03/2005 (7:19 am)
Use Pref::selectedcar or something in the variable field;
#2
08/03/2005 (11:37 am)
I' ve made it, but it doesn't happen nothing, and I was wondering if I must insert something else in the variable field.
And however how the engine understand what to insert togheter with pref::selectedcar?
I explain better:

In the name field, present in selectmission.gui, I insert my name and when you click Start Mission in the pref.cs file the name is written like $pref::Player::name = "XXXXXX"; but the control that you use is a GuiTextEditControl or something similar and obviously the variable field take the text you inserted, but if you apply this behavior to a button, because you want select a car, in which manner the variable field take the parameter to assign to $pref::selectedcar?

fiuuuu what a fatigue, please excuse my english a bit ugly, but I'm italian.

And thanks Billy L for the answer!
#3
08/03/2005 (11:40 am)
I'm not sure a regular button (unless a CheckBox or RadioButton) uses the variable variable.
I would try and manually set the variable and see if that works, like.. in the function.
#4
08/03/2005 (12:08 pm)
Are you using a button or a textfield or something else ?
#5
08/03/2005 (12:08 pm)
You can try making a $pref::selectedcar variable, and make a number of different car datablocks(one for each car). then, you can add a swich statement where you are supposed to load the player into the game, and in each case you can tell the mission to start with a different car.(I'm not sure if this will work, I'm not a coder yet)

good luck,
lee-orr
#6
08/03/2005 (12:50 pm)
I dont know how your car choice is but here is a small example with 2 button and a textfield.
new GuiBitmapButtonCtrl() {
      profile = "GuiCenterTextProfile";
      horizSizing = "right";
      vertSizing = "bottom";
      position = "195 212";
      extent = "140 30";
      minExtent = "8 2";
      visible = "1";
      command = "car.settext(\"Saab\");";
      text = "Saab";
      groupNum = "-1";
      buttonType = "PushButton";
   };
   new GuiBitmapButtonCtrl() {
      profile = "GuiCenterTextProfile";
      horizSizing = "right";
      vertSizing = "bottom";
      position = "194 247";
      extent = "140 30";
      minExtent = "8 2";
      visible = "1";
      command = "car.settext(\"Volvo\");";
      text = "Volvo";
      groupNum = "-1";
      buttonType = "PushButton";
   };
   new GuiTextCtrl(car) {
      profile = "GuiHudTextProfile";
      horizSizing = "right";
      vertSizing = "bottom";
      position = "375 236";
      extent = "8 18";
      minExtent = "8 2";
      visible = "1";
      variable = "pref::selectedcar";
      maxLength = "255";
   };

And i do commercials for Swedish cars lol :)
Edit : deleted some stuff you didnt need .
#7
08/05/2005 (4:39 am)
Thanks really guyz, your support will be mentioned when I'll finish this game, for now I'll try your suggestions, and soon you'll know the results.

Billy L: I'm using a button to select the cars, one button for each type of car.

Byez for now!
#8
08/08/2005 (3:09 am)
OK I tried the proposals, and yes the one made of you, Billy L, worked fine, but now I don't understand why when I set the car selected to the prefs.cs file, this selection doesn't work, I explain better:

Now i have the correct car selected in the prefs.cs file, I recompile the prefs, when I left the selection screen, so the engine has the new prefs, but when the game starts, the car selected is always wrong, prehaps, I thought, that this was a problem linked with the fact that all the .cs files are compiled when the program starts, in particular, the file where I select the correct vehicle.cs is game.cs located in fps/server/scripts, the main game file, it's compiled or readed at the beginning of the program, and then?

I have a global variable ($carType = $pref::Car;) that has assigned the value found in the prefs.cs file and then this code is present:

switch$ ($carType)
{
case ultralight:
exec("./ultralight.cs");

case offroad:
exec("./offroad.cs");

case buggy:
exec("./buggy.cs");

case wmoto:
exec("./wmoto.cs");
}

it's seems to work if I write the cartype by hand, but it's works wrong if it must read the value from the prefs. argh I'm exploding!

Mmmh really I don't understand, nobody knows a car/man/airplane selector that works fine, I think that only studying it I can resolve my problem.....however thanks to all for help me find a solution!

Byez!
#9
08/19/2005 (6:48 am)
Oky guyz, I tried everything and finally I've found the solution, thanks to everyone for the past help, if somebody want to know, I can exxplin in this thread the semi-solution I found, for now I can say only this few words, because my connection isn't a flat and it's too long to explain. Byez and good luck!
#10
10/21/2005 (2:51 pm)
Could you please post the full solution I am trying to do the same and cannot seem to figure it all out.

Thanks
#11
11/02/2005 (2:27 pm)
Actually I would really like to know this as well since I need to know how to assign a value to a preference via a function. In my case I need to store a global variable tha is also a string to a preference.

I have tried:

$pref::player::model = $pModel;

and that does not work. I get "" in my pref.cs.
#12
11/19/2005 (5:16 am)
Yep excuse me for the absence on this thread, soon I'll post the solution I found, I need a connection and for now I'm out on an Internet Point, really ugly this thing. See you later!