+static naRef f_flightplan_indexOfWp(naContext c, naRef me, int argc, naRef* args)
+{
+ FlightPlan* fp = flightplanGhost(me);
+ if (!fp) {
+ naRuntimeError(c, "flightplan.indexOfWP called on non-flightplan object");
+ }
+
+ FGPositioned* positioned = positionedGhost(args[0]);
+ if (positioned) {
+ return naNum(fp->findWayptIndex(positioned));
+ }
+
+ SGGeod pos;
+ int argOffset = geodFromArgs(args, 0, argc, pos);
+ if (argOffset > 0) {
+ return naNum(fp->findWayptIndex(pos));
+ }
+
+ return naNum(-1);
+}
+