Game Development Community

GuiTextCtrl - Change Text Dynamically

by Norv Brooks · in Torque Game Engine · 02/21/2006 (5:04 pm) · 1 replies

I've looked over several forum threads and it looks like it should be simple to change the text in a GuiTextControl from a function within a Scirpt file, but I can't get it to work. The following is an exerpt from my code with some extraneious code removed to highlight issue. Can anyone give me a pointer on this issue either from looking at my code or just the method itself?
Thanks,
Norv

GUI CONTROL CREATED IN GUI EDITOR & TWEAKED IN JEDIT

//--- OBJECT WRITE BEGIN ---
new GuiControl(campHUBOfficeDialogGui) {
Profile = "GuiDialogProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "0 0";
Extent = "800 600";
MinExtent = "8 2";
Visible = "1";

new GuiBitmapCtrl(HUBOfficeFolderCtrl) {
Profile = "GuiWindowProfile";
HorizSizing = "relative";
VertSizing = "relative";
position = "100 100";
Extent = "600 400";
MinExtent = "8 2";
Visible = "1";
bitmap = "./Dialogs/OFFICEFLDR.png";
wrap = "0";
};
new GuiButtonCtrl(OfficeFldrRosterBtn) {
Profile = "GuiButtonProfile";
HorizSizing = "relative";
VertSizing = "relative";
position = "100 100";
Extent = "75 25";
MinExtent = "8 2";
Visible = "1";
Command = "displayRosterPg();";
tooltipprofile = "guiToolTipProfile";
tooltip = "select roster page";
text = "ROSTER";
textID = "OffFldr_Btnroster";
groupNum = "-1";
buttonType = "RadioButton";
};
new GuiTextCtrl(offFldrResourcePtsBalance) {
Profile = "GuiSJDefaultProfile";
HorizSizing = "relative";
VertSizing = "relative";
position = "250 450";
Extent = "300 25";
MinExtent = "8 2";
Visible = "1";
text = "CURRENT RESOURCE POINTS BALANCE :";
textID = "OffFldr_RPBalance";
maxLength = "255";
};
new GuiTextCtrl(offFldrResourcePtsBalTotal) {
Profile = "GuiSJDefaultProfile";
HorizSizing = "relative";
VertSizing = "relative";
position = "550 450";
Extent = "50 25";
MinExtent = "8 2";
Visible = "1";
text = "4000"; ====== TEXT TO BE CHANGED DYNAMICALLY
textID = "OffFldr_RPBalTotal";
maxLength = "255";
};
};

SCRIPT FILE CRATED WITH JEDIT WHICH HAS FUNCTION TO CHANGE TEXT
// campHUBOfficeBtnCtrl
// Vron Software

// Campaign HUB Office Folder
function displayOfficeFolder(){
echo("Office Folder");

Canvas.pushDialog(campHUBOfficeDialogGui);
}

// return to HUB from Office Folder
function returnFromOfficeFolder(){
closeRosterPg();
closeBldgsPg();
Canvas.popDialog(campHUBOfficeDialogGui);
}

// Office Folder functions
function displayRosterPg(){
// make sure other folder pages are closed
closeBldgsPg();

// set Roster heading to visible
OfficeFldrRosterHeading.visible = "1";
// set Roster names & set to visible
%currentSJ1 = $sjRoster::name[0,1,0];
sjCurentRoster1.text = "Randy Brooks";//$sjRoster::name[0,1,0];
//%currentSJ2 = $sjRoster::name[1,1,0];
sjCurentRoster1.visible = "1";

(SOME CODE REMOVED FOR CLARITY)

offFldrResourcePtsBalTotal.text = 2000; //$pref::Player::ResourcePts; ====== VARIABLE TO CHANGE DYNAMICALLY

Canvas.repaint();
}

#1
02/22/2006 (4:39 pm)
I found a forum thread that pointed me in the direction of Ctrl.setText($variable); That got me going.
Thanks to anyone who considered my question.
Norv