+// Returns a ghost handle to the argument to the currently executing
+// command
+static naRef f_cmdarg(naContext c, naRef args)
+{
+ FGNasalSys* nasal = (FGNasalSys*)globals->get_subsystem("nasal");
+ return nasal->cmdArgGhost();
+}
+
+// Sets up a property interpolation. The first argument is either a
+// ghost (SGPropertyNode_ptr*) or a string (global property path) to
+// interpolate. The second argument is a vector of pairs of
+// value/delta numbers.
+static naRef f_interpolate(naContext c, naRef args)
+{
+ SGPropertyNode* node;
+ naRef prop = naVec_get(args, 0);
+ if(naIsString(prop)) node = fgGetNode(naStr_data(prop), true);
+ else if(naIsGhost(prop)) node = *(SGPropertyNode_ptr*)naGhost_ptr(prop);
+ else return naNil();
+
+ naRef curve = naVec_get(args, 1);
+ if(!naIsVector(curve)) return naNil();
+ int nPoints = naVec_size(curve) / 2;
+ double* values = new double[nPoints];
+ double* deltas = new double[nPoints];
+ for(int i=0; i<nPoints; i++) {
+ values[i] = naNumValue(naVec_get(curve, 2*i)).num;
+ deltas[i] = naNumValue(naVec_get(curve, 2*i+1)).num;
+ }
+
+ ((SGInterpolator*)globals->get_subsystem("interpolator"))
+ ->interpolate(node, nPoints, values, deltas);
+}
+
+static naRef f_rand(naContext c, naRef args)
+{
+ return naNum(sg_random());
+}
+