As NW Script is built on C, speaking from a C standpoint...You can't define a function as a parameter. Your first parameter in the declaration of JC_SUB_HERE should be the return of the function or a pointer to it, not the function itself. From what I've read of the language, action is a predefined pointer, and that's why it works in that regard, but the language won't allow you to declare pointers yourself. So the easiest way I could think to pull off what you're wanting to do would be to do something like this:
void JC_SUB_1() {
//Subroutine contents
}
void JC_SUB_2() {
//Another subroutine, why not
}
void JC_SUB_TRIGGER(int JC_SUB_HERE, object oObject, float fDuration, float fInterval) {
int nDuration = FloatToInt(fDuration / fInterval);
int i;
for( i = 0; i < nDuration; i++ ) DelayCommand(IntToFloat(i) * fInterval, AssignCommand(oObject, switch (JC_SUB_HERE){
case 1:
JC_SUB_1();
break;
} ));
}
void main() {
//Our first subroutine, with a duration of 5 seconds and an interval of one quarter of a second...
JC_SUB_TRIGGER(1, OBJECT_SELF, 5.0, 0.25);
//And later in the script, let's have the second subroutine, with a duration of 2 seconds and an interval of one tenth of a second...
DelayCommand(30.0, JC_SUB_TRIGGER(2, OBJECT_SELF, 2.0, 0.1));
}
Although I'm not sure that level of nesting would work, if not you could also try..
void JC_SUB_1() {
//Subroutine contents
}
void JC_SUB_2() {
//Another subroutine, why not
}
void JC_SUB_TRIGGER(int JC_SUB_HERE, object oObject, float fDuration, float fInterval) {
int nDuration = FloatToInt(fDuration / fInterval);
int i;
switch(JC_SUB_HERE){
case 1:
for( i = 0; i < nDuration; i++ ) DelayCommand(IntToFloat(i) * fInterval, AssignCommand(oObject, JC_SUB_1() ));
break;
case 2:
for( i = 0; i < nDuration; i++ ) DelayCommand(IntToFloat(i) * fInterval, AssignCommand(oObject, JC_SUB_2() ));
break;
}
}
void main() {
//Our first subroutine, with a duration of 5 seconds and an interval of one quarter of a second...
JC_SUB_TRIGGER(1, OBJECT_SELF, 5.0, 0.25);
//And later in the script, let's have the second subroutine, with a duration of 2 seconds and an interval of one tenth of a second...
DelayCommand(30.0, JC_SUB_TRIGGER(2, OBJECT_SELF, 2.0, 0.1));
}