Difference between revisions of "Script - Velocity Indicator"

From FreeSpace Wiki
Jump to: navigation, search
m (Notes)
m
Line 1: Line 1:
 
==Function==
 
==Function==
Creates an additional reticle that points towards the real movement direction and also prints the actual velocity (lenght of the velocity vector to the screen)
+
Creates an additional reticle that points towards the real movement direction and also prints the actual velocity (length of the velocity vector to the screen)
  
 
==Table Entry==
 
==Table Entry==

Revision as of 17:43, 15 February 2009

Function

Creates an additional reticle that points towards the real movement direction and also prints the actual velocity (length of the velocity vector to the screen)

Table Entry

#Global Hooks

$GameInit:

[

drawvelret = function(x, y)
   gr.drawGradientLine(x+20,y+20,x+5,y+5)
   gr.drawGradientLine(x-20,y+20,x-5,y+5)
   gr.drawGradientLine(x+20,y-20,x+5,y-5)
   gr.drawGradientLine(x-20,y-20,x-5,y-5)
   gr.drawGradientLine(x,y,x+6,y+6)
   gr.drawGradientLine(x,y,x+6,y-6)
   gr.drawGradientLine(x,y,x-6,y+6)
   gr.drawGradientLine(x,y,x-6,y-6)
end

]

$HUD:

[

position = plr.Position
velocity = plr.Velocity
vlenght = velocity:getMagnitude()
vvector = position + (velocity/(vlenght/2000))

gr.setColor(230,230,100,255)
if vvector:getScreenCoords() ~= false and vlenght > 5 then
   X, Y = vvector:getScreenCoords()
   drawvelret(X, Y)
end

gr.drawString("True Velocity:",435,750)
gr.drawString(math.floor(vlenght),575,750)

]

#End

Notes

Current version is meant for 1024 x 768 resolution. Final position of the True Velocity: xxx gauge is yet to be determined.