Using Tribes from Groove's installer, I altered the vbackground script so I can cycle through crosshairs. It works well, except that I have to revert to one particular crosshair (whatever I decide is the 'default') every time I start tribes. If I don't revert to the 'default', Tribes either crashes on startup or produces a black screen with a ghosting tribes cursor. It's not a big deal, but if it's easily solvable, I'd like to know.
The code looks like this:
At the moment, I have to set $pref::vhud::Xhair::style in the autoexec to be whatever is set in Xhairs::Init, otherwise I get the crash described above. Any ideas why? Also, what is the BG::NoSleep in the Init and why is it important?
Thanks!
The code looks like this:
Code:
// Modified Groove's background changer to cycle
// through pre-configured crosshairs.
function Xhairs::Init() {
if($Xhairs:Loaded)
return;
$Xhairs:Loaded = true;
HUD::New( "Xhair::Container", 0, 0, 128, 128, BG::NoSleep, BG::NoSleep );
newObject("Xhair::Xhair", FearGuiFormattedText, 0, 0, 128, 128);
HUD::Add("Xhair::Container","Xhair::Xhair");
Control::SetValue("Xhair::Xhair", "<B0,0:Modules/Xhairs/green_white_cross.png>");
}
Xhairs::Init();
$Xhairchange::Color[1] = "Green with White Cross";
$Xhairchange::Color[2] = "Green with White Circle";
$Xhairchange::Color[3] = "Green with Red Circle";
$Xhairchange::Color[4] = "Red with White Circle";
$Xhairchange::Color[5] = "Small Red Cross";
$Xhairchange::Color[6] = "Green Dot";
$Xhairchange::Color[7] = "Red Dot";
$Xhairchange::Color[8] = "White Dot";
$Xhairchange::Color[9] = "Blank";
$Xhairchange::currentstyle = 1;
// increment counter, loop at 9, set pref, remoteBP style name, apply the style
function Xhairchange::styleup() {
$Xhairchange::currentstyle += 1;
if ($Xhairchange::currentstyle > 9) $Xhairchange::currentstyle = 1;
$pref::vhud::Xhair::style = $Xhairchange::Color[$Xhairchange::currentstyle];
remoteBP(2048, "<jc><f1>Xhair Style set to <f2>" @ $Xhairchange::Color[$Xhairchange::currentstyle] @ ".", 2);
Xhairchange::applystyle();
}
// apply the texture settings changes for the various styles
function Xhairchange::applystyle()
{
switch($pref::vhud::Xhair::style)
{
case "Green with White Cross":
Xhairchange::default();
break;
case "Green with White Circle":
Control::SetValue("Xhair::Xhair", "<B0,0:Modules/Xhairs/green_cross_white_circle.png>");
break;
case "Green with Red Circle":
Control::SetValue("Xhair::Xhair", "<B0,0:Modules/Xhairs/green_cross_red_circle.png>");
break;
case "Red with White Circle":
Control::SetValue("Xhair::Xhair", "<B0,0:Modules/Xhairs/red_white_circle.png>");
break;
case "Small Red Cross":
Control::SetValue("Xhair::Xhair", "<B0,0:Modules/Xhairs/small_red_cross.png>");
break;
case "Green Dot":
Control::SetValue("Xhair::Xhair", "<B0,0:Modules/Xhairs/green_dot.png>");
break;
case "Red Dot":
Control::SetValue("Xhair::Xhair", "<B0,0:Modules/Xhairs/red_dot.png>");
break;
case "White Dot":
Control::SetValue("Xhair::Xhair", "<B0,0:Modules/Xhairs/white_dot.png>");
break;
case "Blank":
Control::SetValue("Xhair::Xhair", "<B0,0:Modules/Xhairs/blank.png>");
break;
default:
Xhairchange::default();
break;
}
}
function Xhairchange::default() {
Control::SetValue("Xhair::Xhair", "<B0,0:Modules/Xhairs/green_white_cross.png>");
}
//hack to insert binds into the menu
function Xhairchange::addBindsToMenu() after GameBinds::Init
{
$GameBinds::CurrentMap = "actionMap.sae";
$GameBinds::CurrentMapHandle = GameBinds::GetActionMap2( "actionMap.sae" );
GameBinds::addBindCommand( "Change Crosshair Style", "Xhairchange::styleup();", "" );
}
Event::attach(eventGuiOpen, Xhairchange::applystyle);
At the moment, I have to set $pref::vhud::Xhair::style in the autoexec to be whatever is set in Xhairs::Init, otherwise I get the crash described above. Any ideas why? Also, what is the BG::NoSleep in the Init and why is it important?
Thanks!