One puzzle problem
by Ken · in Torque Game Builder · 07/05/2005 (8:18 pm) · 1 replies
I add some buttons at rum time .it's code is bellow:
for(%i = 0; %i<$g_ServerNum;%i++)
{
new GuiBitmapButtonCtrl(server11gui @ %i)
{
profile = "GuiDefaultProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "185" SPC 129+45*%i;
extent = "191 45";
minExtent = "8 2";
visible = "1";
command = "GuiBitmapButtonCtrl::SetV();";
text = "Button";
groupNum = "-1";
buttonType = "PushButton";
bitmap = "./gui/guiimage/login/f_006";
sn = %i; //dynamic field;
};
login.add(server11gui @ %i);
}
function GuiBitmapButtonCtrl::SetV()
{
$sn = %this.sn;
echo($sn);
}
I want that I click one button,then I can get this button' sn ;
but I failed .what wrong with me?
for(%i = 0; %i<$g_ServerNum;%i++)
{
new GuiBitmapButtonCtrl(server11gui @ %i)
{
profile = "GuiDefaultProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "185" SPC 129+45*%i;
extent = "191 45";
minExtent = "8 2";
visible = "1";
command = "GuiBitmapButtonCtrl::SetV();";
text = "Button";
groupNum = "-1";
buttonType = "PushButton";
bitmap = "./gui/guiimage/login/f_006";
sn = %i; //dynamic field;
};
login.add(server11gui @ %i);
}
function GuiBitmapButtonCtrl::SetV()
{
$sn = %this.sn;
echo($sn);
}
I want that I click one button,then I can get this button' sn ;
but I failed .what wrong with me?
Torque Owner Gary Preston
Then change your function to be
function GuiBitmapButtonCtrl::SetV(%this) { $sn = %this.sn; echo($sn) }Also unless you're using $sn elsewhere, you should make $sn local using %sn instead.