Advertisement
Guest User

Speed

a guest
Dec 21st, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.69 KB | None | 0 0
  1. // Simple vSpeedHUD for Tribes 1.40 w/GreyHounds ScriptGL
  2. // modeled after the example scripts included with ScriptGL
  3.  
  4. function vhud::SpeedHUD::create()
  5. {
  6.     // if this hud is already loaded, stop here
  7.     if ( $vSpeedHUD::Loaded )
  8.         return;
  9.    
  10.     // a stupid global variable that says this hud is loaded   
  11.     $vSpeedHUD::Loaded = true;
  12.  
  13.     // create a scriptGL hud - configs without vhudmover ignore all but the first and last of these vars
  14.     vhud::create( "ScriptGL::vSpeedHUD", "0% 0%", "0% 0%", vhud::vSpeedHUD::onrender );
  15.     // create a native tribes hud so you have something to drag with the stock hudmover
  16.     // HUD::New("hud name here", positionX, positionY, ExtentX, ExtentY, wakefunction, sleepfunction)
  17.     HUD::New("ScriptGL::vSpeedHUD", 365, 0, 88, 20, vSpeed::WakeSleep, vSpeed::WakeSleep);
  18. }
  19.  
  20. // normal huds go to 'sleep' when you tab out - we just have a blank function here to avoid console errors :P
  21. function vSpeed::WakeSleep() { }
  22.  
  23. // the ScriptGL hud
  24. function vhud::vSpeedHUD::onrender()
  25. {
  26.     // dont draw anywhere but playGui (ingame)
  27.     if($Scriptgl::CurrentGui != "playGui")
  28.         return;
  29.        
  30.     // dont draw if set to hidden  
  31.     if(!Control::getVisible("ScriptGL::vSpeedHUD"))
  32.         return;
  33.        
  34.     // local variables to find where our hud is so we know where to draw stuff
  35.     %pos = Control::getposition("ScriptGL::vSpeedHUD");
  36.     %position[x] = getWord(%pos,0);
  37.     %position[y] = getWord(%pos,1);
  38.     %size = Control::getExtent("ScriptGL::vSpeedHUD");
  39.     %size[x] = getWord(%size,0);
  40.     %size[y] = getWord(%size,1);
  41.    
  42.        
  43.     // i think this is like the red pill that resets the GL matrix
  44.     glLoadIdentity();
  45.  
  46.     // setup GL options
  47.     glDisable($GL_TEXTURE_2D);
  48.     glDisable($GL_SCISSOR_TEST);
  49.     glEnable($GL_ALPHA_TEST);
  50.     glBlendFunc($GL_SRC_ALPHA,$GL_ONE_MINUS_SRC_ALPHA);
  51.     glAlphaFunc($GL_GREATER,$GL_ZERO);
  52.    
  53.    
  54.     // this is the color and opacity of the background box in RGBA 0-255
  55.     glColor4ub( 0, 0, 0, 150 );
  56.    
  57.     // this is the background box - should draw as big as the extent settings in our original HUD::New
  58.     glBegin($GL_QUADS);
  59.         glVertex2f(%position[x] , %position[y]);
  60.         glVertex2f(%position[x] + %size[x], %position[y]);
  61.         glVertex2f(%position[x] + %size[x], %position[y] + %size[y]);
  62.         glVertex2f(%position[x] , %position[y] + %size[y]);
  63.     glEnd();
  64.    
  65.     // font and size
  66.     glSetFont( "calibri", 14, 0, 9 );
  67.     // font draw color in R,G,B,A 0-255
  68.     glColor4ub( 255,  255,  255,  255 );
  69.     // draw the word 'Speed: ' at whatever position in the hud. in this case it's 2 pixels to the right and 2 down
  70.     glDrawString(%position[x] + 2,%position[y] + 2, "Speed: " );
  71.     // draw the value of $speed 55 pixels to the right and 2 down
  72.     glDrawString(%position[x] + 55, %position[y] + 2, $Speed );
  73.  
  74. }
  75.  
  76. vhud::SpeedHUD::create();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement