New question..
I did as you said, now, I need to allow those functions to access members of an NPCObject class. NPCObject has a function pointer that will point to one of the functions pointed to by the pointers in the array.
Hard to explain, so let me show you the code I'm talking about...
// First, we have the code of the functions themselves...
void ticks0()
{
// here, I want to have some code that accesses NPCObject's members (is this possible?). NPCObject will have a function pointer pointing to this function.
}
void ticks1()
{
}
// etc...
// and the array:
void (*ticks[30])() = { &ticks0, &ticks1, &ticks2, &ticks3, &ticks4, &ticks5, &ticks6, &ticks7, &ticks8,
&ticks9, &ticks10, &ticks11, &ticks12, &ticks13, &ticks14, &ticks15, &ticks16, &ticks17,
&ticks18, &ticks19, &ticks20, &ticks21, &ticks22, &ticks23, &ticks24, &ticks25, &ticks26,
&ticks27, &ticks28, &ticks29 };
class NPCObject
{
public:
void (*action)(); // "script" pointer.. function called when the player "talks" to the NPC
void (*tick)(); // "script" pointer.. function to be called each frame
};
Then, in one of NPCObject's functions:
tick = ticks[tick_id];
action = actions[action_id];