if ( !isObject( "testPlayGUI" ) )
{
new gameTSCtrl( "testPlayGUI" )
{
visible = true;
noCursor = true;
};
}
if ( !isObject( "energyHUD" ) )
{
new guiSwatchCtrl( "energyHUD" )
{
position = "0 0";
extent = "175 24"; // 138 24
visible = true;
color = "0 0 0 0";
};
for ( $index = 0 ; $index < 10 ; $index++ )
{
$obj = new guiBitmapButtonCtrl()
{
position = 37 + 14 * $index SPC 0;
extent = "12 24";
visible = true;
mColor = "25 55 55 127";
text = "";
bitmap = "./energy";
};
energyHUD.add( $obj );
energyHUD.cell[ $index ] = $obj;
}
energyHUD.text = new guiMLTextCtrl()
{
position = "0 0";
extent = "33 25";
visible = true;
text = "<font:digital-7 mono:25><color:193737>000";
};
$index = "";
$obj = "";
energyHUD.add( energyHUD.text );
testPlayGUI.add( energyHUD );
}
function testPlayGUI::onWake( %this )
{
playGui::onWake( %this );
%res = getRes();
energyHUD.position = getWord( %res, 0 ) - 187 SPC getWord( %res, 1 ) - 32;
}
function testPlayGUI::onSleep( %this )
{
playGui::onSleep( %this );
}
If I execute this code after the game started, doing this works: canvas.setContent(testPlayGUI);
Otherwise, if it executes during the add-on loading process, Blockland simply crashes when I enter the above into the console.