Can True/False be assigned to a Variable via GuiCheckBoxCtrl()?
by James Owen · in Torque Game Engine · 11/21/2004 (1:34 pm) · 3 replies
Eg. In the following code, I want to assign $Game::Cycling to be True if the checkbox is checked, and False if the checkbox isn't checked.
How should I implement it via GuiCheckBoxCtrl() ?
new GuiCheckBoxCtrl() {
profile = "GuiCheckBoxProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "255 295";
extent = "147 23";
minExtent = "8 8";
visible = "1";
variable = "$Game::Cycling";
text = "Cycle Game ?";
groupNum = "-1";
buttonType = "ToggleButton";
helpTag = "0";
maxLength = "255";
};
Thank you.
How should I implement it via GuiCheckBoxCtrl() ?
new GuiCheckBoxCtrl() {
profile = "GuiCheckBoxProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "255 295";
extent = "147 23";
minExtent = "8 8";
visible = "1";
variable = "$Game::Cycling";
text = "Cycle Game ?";
groupNum = "-1";
buttonType = "ToggleButton";
helpTag = "0";
maxLength = "255";
};
Thank you.
#2
function onGameDurationEnd()
{
if ($Game::Duration && !isObject(EditorGui) &&$Game::Cycling)
cycleGame();
}
Any suggestion?
Much appreciated :)
Thank you.
11/21/2004 (10:05 pm)
After inserting the GuiCheckBoxCtrl() code, I have the checkbox for player to check if they want to cycle the game. However, whether the checkbox is checked or unchecked, cyclegame() will not run in OnGameDurationEnd(). Removing <&& $Game::Cycling> from the condition will allow the game to cycle again.function onGameDurationEnd()
{
if ($Game::Duration && !isObject(EditorGui) &&$Game::Cycling)
cycleGame();
}
Any suggestion?
Much appreciated :)
Thank you.
#3
function cycleGame() {
if (!$Game::Cycling) { ------------------(1)
$Game::Cycling = true; ------------(2)
....
Don't know why they are there, but you just have to uncomment (1) and (2). Then your code for onGameDurationEnd()
should be working as intended.
Hope that helps.
11/22/2004 (5:35 pm)
Akhran, if you're using the codes from Ken Finney's Book, then I would suggest you trace the program from cycleGame(). I think there is a line in the code that reverse the True/False of your $Game:Cycling. It goes something like this:function cycleGame() {
if (!$Game::Cycling) { ------------------(1)
$Game::Cycling = true; ------------(2)
....
Don't know why they are there, but you just have to uncomment (1) and (2). Then your code for onGameDurationEnd()
should be working as intended.
Hope that helps.
Torque Owner Stefan Lundmark
The example you provided should be enough. But you need to store the data somewhere.