Before I stall any longer here's the animation script. I haven't got everything I wanted in it yet, but there's enough for thrust vectoring, thrust nozzles and landing gear systems. Also if someone wants to write this in a more understandable instructions please do!!!
This is an alpha build so it's probably buggy and not the best of handling everything, but it's a start.
There's a few things you must do beforehand to get everything working.
1. The subobject's axises must be aligned with that of the ships (i.e. the subobjects x axis must be parallel to the ships x, same for y & z). If they're not they won't rotate correctly (in fact they'll rotate on the ships axis rather than the subsystem's) If someone can find a solution for this please let me know!
If the subsystem's doesn't match up, you must rotate them to be parallel. Remember what those rotation coordinates are, you'll need them later!!! Finally preform a x-form reset (or equivalent) to force it aligned. Don't worry you'll be providing those angles later and will appear correctly in-game
2. The subsystem must be visible to fred (i.e. have a $special=subsystem and $name=blah) and the appropriate ship table entries. Otherwise nothing will happen
3. copy the animation-sct.tbm into the tables folder and load it with your favorite editor (notepad++ hint hint)
4. Scroll down to ShipType:RegisterShip (about line 1278)
function ShipType:RegisterShip ()
local ship = self:GetRealShip ()
if (ship.Class.Name == "F-104D Bearcat") then
self:RegisterBearcat ()
--*****************************************************************************************************
-- UPDATE ME
-- Add different ship classes as needed here
--*****************************************************************************************************
end
self:SetInitialOrientation ()
end
you'll need to add your new ship type here. Let's say for example you made "GTSV Hercules Mk X"
you would add this:
elseif (ship.Class.Name == "GTSV Hercules Mk X") then
self:RegisterGTSVHercules ()
Warning! Renaming your ship latter will require this to be altered to.! (Is there a way in lua to retrieve the $short name for a ship? that would be much safer)
5. Next we need to create the RegisterGTSVHercules. Jump down to line 1451 (ShipType:RegisterBearcat ())
This is a template for your ship. copy this function (1456 to 1623) and paste it. Rename it to that function name (in this case "RegisterGTSVHercules"
6. There's quite a bit here you probably won't need. If your looking to do landing gears the stuff in "testing == 1" is what you want to look at (1470-1583). Thrust vectoring, nozzling is the second half (1586-1621)
I hope I left enough comments in there to help you. There's two different ship models i used, one was my bearcat with landing gears and the other a box with vectoring engines.
Also remember back when I said to remember those coordinates if the axises didn't align, those go in the Offset. The second parameter for RegisterLandingGearSubsystem, RegisterThrustVectorSubsystem, RegisterThrustVelocitySubsystem. I.e. let's say you had a subobject "PortLandingGear" that was off ship axis. You rotated it till it was on. Let's say (-10,0,0). RegisterLandingGear... would look like this:
self:RegisterLandingGearSubsystem ("PortLandingGear" ba.createVector (math.rad (10),0,0),......
Note the angle is the negative if what we first saw. We want the offset to be the angle from the ships (0,0,0) to where the subsystem should first show up as. Hope that made sense
7. That should be it for lua coding! WHEW!
8. In FRED you'll want to luascript these functions: OpenLandGear ("ShipName") CloseLandGear ("ShipName") ToggleLandGear ("ShipName")
Ugh too big for code. Grab it here:
Version 0.201
http://scoobydoo.freespacemods.net/AnimBeta/0.201-animation-sct.tbmVersion .2
http://scoobydoo.freespacemods.net/AnimBeta/0.2-animation-sct.tbmVersion .12
http://scoobydoo.freespacemods.net/AnimBeta/0.12-animation-sct.tbmVersion .11
http://scoobydoo.freespacemods.net/AnimBeta/0.11-animation-sct.tbmVersion .1
http://scoobydoo.freespacemods.net/AnimBeta/0.1-animation-sct.tbm