Script - Escort Reticle: Difference between revisions

Wanderer (talk | contribs)
new page
 
The Force (talk | contribs)
Undo revision 38729 by Hired (Talk)
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==Function==
Creates an additional reticle around all ships in the escort list. This script needs a nightly build revision 5834 or later to work.
Creates an additional reticle around all ships in the escort list and also displayes ships name below the reticle
==Table Entry==
<pre>#Conditional Hooks


==Table Entry==
$Application: FS2_Open
<pre>#Global Hooks


$GameInit:
$On Game Init:
[
drawReticle = function(ship)
if    ship.Team.Name == "Hostile"  then gr.setColor(255,50,50,255)
elseif ship.Team.Name == "Friendly" then gr.setColor(0,255,0,255)
elseif ship.Team.Name == "Unknown"  then gr.setColor(255,255,0,255)
end
local x
local y
local x1
local y1
x,y,x1,y1 = gr.drawTargetingBrackets(ship, true)
if x ~= nil and y1 ~= nil then gr.drawString(ship.Name, x, y1 + 4) end
end
]


$On HUD Draw:
[
[


escortReticle = function(x1, y1, name)
if missiontime == nil then
   gr.drawGradientLine(x1, y1+36, x1+8, y1+24)
   missiontime = mn.getMissionTime()
   gr.drawGradientLine(x1, y1+36, x1-8, y1+24)
   oldmissiontime = missiontime
  gr.drawGradientLine(x1+24, y1, x1+16, y1+12)
end
  gr.drawGradientLine(x1-24, y1, x1-16, y1+12)
 
  gr.drawGradientLine(x1, y1-36, x1+8, y1-24)
if missiontime ~= nil then
  gr.drawGradientLine(x1, y1-36, x1-8, y1-24)
if hu.HUDDrawn then
  gr.drawGradientLine(x1+24, y1, x1+16, y1-12)
missiontime = mn.getMissionTime()
  gr.drawGradientLine(x1-24, y1, x1-16, y1-12)
if oldmissiontime ~= missiontime then
  gr.drawString(name,x1-36,y1+48)
        if mn.EscortShips ~= nil then
        NumberEscorted = #mn.EscortShips
        for i= 1,NumberEscorted do
        escortedship = mn.EscortShips[i]
        if escortedship.Position:getScreenCoords() ~= false then
        drawReticle(escortedship)
        end
        end
        end
end
end
oldmissiontime = missiontime
end
end


]
]


$HUD:
#End</pre>
 
 
[[Category:Scripting Examples|Escort Reticle]]


==Alternative Table Entry==
<pre>#Conditional Hooks
$Application: FS2_Open
$On Game Init:
[
drawReticle = function(ship)
if    ship.Team.Name == "Hostile"  then gr.setColor(255,50,50,255)
elseif ship.Team.Name == "Friendly" then gr.setColor(0,255,0,255)
elseif ship.Team.Name == "Unknown"  then gr.setColor(255,255,0,255)
end
local x
local y
local x1
local y1
plr = hv.Player
if plr:isValid() then
distance = ship.Position:getDistance(plr.Position)
-- collision_pos = ship:checkRayCollision(plr.Position, ship.Position, false)
-- distance = collision_pos:getDistance(plr.Position)
end
hippo_pct = math.floor((ship.HitpointsLeft / ship.Class.HitpointsMax) * 100)
x,y,x1,y1 = gr.drawTargetingBrackets(ship, true)
if x ~= nil and y1 ~= nil then
gr.drawString(ship.Name, x+3, y+2)
gr.drawString(ship.Class.Name, x+3, y+11)
gr.drawString(hippo_pct, x+3, y+20)
gr.drawString(distance, x+3, y+29)
end
end
]
$On HUD Draw:
[
[


for i=1, mn.getNumEscortShips() do
if missiontime == nil then
   escortedship = mn.getEscortShipByIndex(i)
   missiontime = mn.getMissionTime()
   X, Y = escortedship.Position:getScreenCoords()
   oldmissiontime = missiontime
  if escortedship.Position:getScreenCoords() ~= false and escortedship.Team.Name == "Hostile" then
end
      gr.setColor(255,50,50,255)
 
      escortReticle(X, Y, escortedship.Name)
if missiontime ~= nil then
  end
if hu.HUDDrawn then
  if escortedship.Position:getScreenCoords() ~= false and escortedship.Team.Name == "Friendly" then
missiontime = mn.getMissionTime()
      gr.setColor(0,255,0,255)
if oldmissiontime ~= missiontime then
      escortReticle(X, Y, escortedship.Name)
        if mn.EscortShips ~= nil then
  end
        NumberEscorted = #mn.EscortShips
  if escortedship.Position:getScreenCoords() ~= false and escortedship.Team.Name == "Unknown" then
        for i= 1,NumberEscorted do
      gr.setColor(255,255,0,255)
        escortedship = mn.EscortShips[i]
      escortReticle(X, Y, escortedship.Name)
        if escortedship.Position:getScreenCoords() ~= false then
  end
        drawReticle(escortedship)
        end
        end
        end
end
end
oldmissiontime = missiontime
end
end


Line 47: Line 117:


#End</pre>
#End</pre>
[[Category:Scripting Examples|Escort Reticle]]

Latest revision as of 08:44, 19 June 2012

Creates an additional reticle around all ships in the escort list. This script needs a nightly build revision 5834 or later to work.

Table Entry

#Conditional Hooks

$Application: FS2_Open

$On Game Init:
[
drawReticle = function(ship)
	if     ship.Team.Name == "Hostile"  then gr.setColor(255,50,50,255)
	elseif ship.Team.Name == "Friendly" then gr.setColor(0,255,0,255)
	elseif ship.Team.Name == "Unknown"  then gr.setColor(255,255,0,255)
	end
	local x 
	local y
	local x1
	local y1 
	x,y,x1,y1 = gr.drawTargetingBrackets(ship, true)
	if x ~= nil and y1 ~= nil then gr.drawString(ship.Name, x, y1 + 4) end
end
]

$On HUD Draw:
[

if missiontime == nil then
   missiontime = mn.getMissionTime()
   oldmissiontime = missiontime
end

if missiontime ~= nil then
	if hu.HUDDrawn then
	missiontime = mn.getMissionTime()
		if oldmissiontime ~= missiontime then
        		if mn.EscortShips ~= nil then
	        		NumberEscorted = #mn.EscortShips
		        	for i= 1,NumberEscorted do
	        			escortedship = mn.EscortShips[i]
        				if escortedship.Position:getScreenCoords() ~= false then
		        			drawReticle(escortedship)
			        	end
         			end
	        	end
		end
	end
	oldmissiontime = missiontime
end

]

#End


Alternative Table Entry

#Conditional Hooks

$Application: FS2_Open

$On Game Init:
[
drawReticle = function(ship)
	if     ship.Team.Name == "Hostile"  then gr.setColor(255,50,50,255)
	elseif ship.Team.Name == "Friendly" then gr.setColor(0,255,0,255)
	elseif ship.Team.Name == "Unknown"  then gr.setColor(255,255,0,255)
	end
	local x
	local y
	local x1
	local y1
	plr = hv.Player
	if plr:isValid() then
		distance = ship.Position:getDistance(plr.Position)
--		collision_pos = ship:checkRayCollision(plr.Position, ship.Position, false)
--		distance = collision_pos:getDistance(plr.Position)
	end
	hippo_pct = math.floor((ship.HitpointsLeft / ship.Class.HitpointsMax) * 100)
	x,y,x1,y1 = gr.drawTargetingBrackets(ship, true)
	if x ~= nil and y1 ~= nil then
		gr.drawString(ship.Name, x+3, y+2)
		gr.drawString(ship.Class.Name, x+3, y+11)
		gr.drawString(hippo_pct, x+3, y+20)
		gr.drawString(distance, x+3, y+29)
	end
end
]

$On HUD Draw:
[

if missiontime == nil then
   missiontime = mn.getMissionTime()
   oldmissiontime = missiontime
end

if missiontime ~= nil then
	if hu.HUDDrawn then
	missiontime = mn.getMissionTime()
		if oldmissiontime ~= missiontime then
        		if mn.EscortShips ~= nil then
	        		NumberEscorted = #mn.EscortShips
		        	for i= 1,NumberEscorted do
	        			escortedship = mn.EscortShips[i]
        				if escortedship.Position:getScreenCoords() ~= false then
		        			drawReticle(escortedship)
			        	end
         			end
	        	end
		end
	end
	oldmissiontime = missiontime
end

]

#End