Well, it don't get error messages anymore, but I'm not seeing any models rendered either.
This is the current script:
#Conditional Hooks
$Application: Freespace 2
$On Game Init: [
GrappleHook = {}
GrappleHook.Grapples = {}
GrappleHook.HookModel = "cable.pof"
function GrappleHook.addGrappleHook(weapon, shipHit)
local newGrapple = {}
--Don't add grapples if
--(1) Nil was passed
--(2) Weapon is dead
--(3) Weapon has no parent
if not weapon or not weapon:isValid() or not weapon.Parent:isValid()then
return
end
--This is inaccurate - no real way to tell where this
--grapple came from on the source ship right now, besides
--explicitly telling it in the script
--newGrapple.startShip = weapon.Parent
--newGrapple.StartLocalPosition = ba.newVector(0, 0, 0)
--This is more accurate
newGrapple.EndShip = shipHit
newGrapple.EndLocalPosition = weapon.Position - shipHit.Position
--I don't remember if this is right or not
newGrapple.EndLocalOrientation = weapon.Orientation * shipHit.Orientation:getTranspose()
table.insert(GrappleHook.Grapples, newGrapple)
end
function GrappleHook.doFrame()
for k,g in pairs(GrappleHook.Grapples) do
--Renders grappling hook in the same position that it hit at
gr.drawModel(GrappleHook.HookModel, g.Endship.Position + g.EndLocalPosition, g.EndShip.Orientation * g.EndOrientation)
end
end
]
$Application: Freespace 2
$State: GS_STATE_PLAY_GAME
$On Frame: [
time = mn.getMissionTime()
if time ~= nil and GrappleHook ~= nil then
GrappleHook.doFrame()
end
]
$Application: Freespace 2
$Weapon Class: Grapple
$On Ship Collision: [
GrappleHook.addGrappleHook(hv.Weapon, hv.Ship)
]
#End