#Global Hooks
$GameInit:
[
drawLeftArrow = function()
gr.setColor(16,21,16)
gr.drawRectangle(1,1,12,100,false)
gr.setColor(79,104,79)
gr.drawLine(2,50,11,2)
gr.drawLine(2,50,11,99)
gr.drawLine(11,2,11,99)
end
drawRightArrow = function()
gr.setColor(16,21,16)
gr.drawRectangle(1012,1,1024,100,false)
gr.setColor(79,104,79)
gr.drawLine(1013,2,1023,50)
gr.drawLine(1013,99,1023,50)
gr.drawLine(1013,2,1013,99)
end
drawPanel = function(number)
gr.setColor(16,21,16)
gr.drawRectangle(12+(200*number),1,212+(200*number), 100, false)
gr.drawRectangle(13+(200*number),2,211+(200*number), 99, false)
end
scrollPanel = function(curScroll, change)
curScroll = curScroll + change
return curScroll
end
]
$HUD:
[
if missionInit == nil then
missionInit = 42
topScroll = 1
end
shipInFocus = mn.Ships['GTC Orff']
numFocusSubsys = #shipInFocus
numShips = #mn.Ships
io.setMouseHidden(false)
drawLeftArrow()
--PANEL STUFF!
for i = 0, 4 do
drawPanel(i)
thisPanel = topScroll + i
textStart = (200*(i+1)) - 180
thisSubsystem = shipInFocus[thisPanel] --This Subsystem's Handle
thisSubsystemName = thisSubsystem:getName() --This Subsystem's Name
thisSubsysTargetPos = thisSubsystem.Target.Position --This Subsystem's Target
--if thisSubsystem.Target:isValid() then
-- realTarget = thisSubsystem.Target.Name
--else
-- realTarget = nil
--end
target = thisSubsystem.Target
if target:isValid() then
realTarget = target:getBreedName()
if realTarget == "Ship" then
realTarget = target.Name
end
end
thisSubsysHealth = math.floor((thisSubsystem.HitpointsLeft / thisSubsystem.HitpointsMax)*100)
thisSubsysPosition = thisSubsystem.Position
if #thisSubsystem.PrimaryBanks ~= 0 then --do we have Primaries?
thisWeaponName = thisSubsystem.PrimaryBanks[1].WeaponClass.Name --Sorta hackish, I'm just going to assume the first bank is the same as the rest
elseif #thisSubsystem.SecondaryBanks ~= 0 then --or Secondaries?
thisWeaponName = thisSubsystem.SecondaryBanks[1].WeaponClass.Name
else --or uh, nothing at all?
thisWeaponName = nil
end
-- <hack>
--realTarget = nil
--for j=1, numShips do
-- targetShip = mn.Ships[j]
-- thisPosition = targetShip.Position
-- if thisSubsysTargetPos[1] == thisPosition[1] and thisSubsysTargetPos[2] == thisPosition[2] and thisSubsysTargetPos[3] == thisPosition[3] then
-- realTarget = targetShip.Name
-- end
--end
-- </hack>
--DRAWING PANEL INFO STARTS HERE
gr.setColor(79,104,79)
gr.drawString("Panel " .. thisPanel, textStart, 10) --Draw Subsystem Number
gr.drawString(thisSubsystemName, textStart, 20) --Draw Subsystem Name
if thisWeaponName ~= nil then --Draw Subsystem Weapon (if any)
gr.drawString("Weapon: " .. thisWeaponName, textStart, 30)
end
if realTarget == nil then --Draw Subsystem Target
gr.drawString("Target: None",textStart,40)
else
gr.drawString("Target: " .. realTarget,textStart,40)
end
if thisSubsysHealth < 25 then
gr.setColor(192,0,0)
elseif thisSubsysHealth < 50 then
gr.setColor(255,242,0)
elseif thisSubsysHealth < 75 then
gr.setColor(247,148,29)
end
gr.drawString("Strength: " .. thisSubsysHealth .. "%",textStart,50) --Draw Subsystem Health
--DRAW ONSCREEN STUFF HERE
end
drawRightArrow()
--SHIP STUFF
thisShipName = shipInFocus.Name
thisShipClass = shipInFocus.Class.Name
thisShipHealth = math.floor((shipInFocus.HitpointsLeft/shipInFocus.HitpointsMax)*100)
gr.setColor(79,104,79)
gr.drawString(thisShipName, 750, 500)
gr.drawString(thisShipClass, 750, 510)
gr.drawString(thisShipHealth, 750, 520)
--CLICKING STUFF
--Need to clean this up so one click = one panel change
--Go down panel list
if io.isButtonDown(MOUSE_LEFT_BUTTON) and io.getX() > 2 and io.getY() > 2 and io.getX() < 11 and io.getY() < 99 then
if topScroll > 1 then
topScroll = scrollPanel(topScroll, -1)
end
end
--Go up panel list
if io.isButtonDown(MOUSE_LEFT_BUTTON) and io.getX() > 1013 and io.getY() > 2 and io.getX() < 1023 and io.getY() < 99 then
if (topScroll + 4) < numFocusSubsys then
topScroll = scrollPanel(topScroll, 1)
end
end
]
#End