i believe there are functions (or events) to make a ship face a world space vector, so if you have a vector to the target you can have your ship follow it until its within optimal weapons range. if you want to do a broadside, at this point, you would just need to come up with a new vector target. just rotate the world vector about your ship 90 degrees.
v = ba.createOrientation(0,0,math.pi/2):unrotateVector(target.position - self.position)+self.position
of course this assumes the mission is laid out fairly flat and that ships keep themselves level to the grid. you dont want ships to end up on their sides so that the target is outside of a turret's firing arc. to make this a better solution, follow that up by periodically ploting a new target vector, say when you get within x distance of the current target vector, plot a new vector and follow it. you can start by plotting a vector forward vector. you can just take the ships velocity times 10 (where it will be in ~10 seconds, assuming thrust is constant). you can then rotate that vector into the target's space, normalize it, and multiply it by your desired distance:
--get a world vector from your velocity
vvec = self.physics.velocity*10 + self.position
--put it int your target's space
lv = target.orientation:rotateVector(vvec - target.position)
--scale it to the optimal firing range (normalize and scale)
lvlenr = 1/lv:getmagnitude()
lv = lv * lvlenr * desiredRange
--put it back into world space
newv = target.positon + target.orientation:unrotateVector(lv)
resulting in a vector that is in front of you and at the appropriate distance for a broadside. while your are chasing these vectors, have the ship adjust its orientation to keep the correct side of the ship facing the target. you can also do other things like try to keep the ships level to the mission, but that is not a strict requirement. you can for example take a side vector (1,0,0) and unrotate it by the ships's orientation, and dot it with (target.position-self.position):getNormalized(). if its greater than 0 its facing the target, otherwise its facing away (you want to get a value close to 1), and if you get the acos of that value, you know how many degrees radians you need to roll to face the broadside towards the target.