Difference between revisions of "Script - Velocity Indicator"

From FreeSpace Wiki
Jump to: navigation, search
(new page)
 
m (Notes)
Line 45: Line 45:
  
 
==Notes==
 
==Notes==
Current version is ment for 1024 x 768 resolution. Final position of the '''True Velocity:  xxx''' gauge is yet to be determined.
+
Current version is meant for 1024 x 768 resolution. Final position of the '''True Velocity:  xxx''' gauge is yet to be determined.
  
 
[[Category:Scripting Examples|Velocity Indicator]]
 
[[Category:Scripting Examples|Velocity Indicator]]

Revision as of 22:47, 6 January 2009

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)

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.