Originally Posted By: JustSid
Write a runtime that gets called wenn calling a function in a struct. In this function set a pointer called this to the struct and then call the actual function.

It's that easy.


Yep exactly as JustSid said, but here's an example with that:

usage of "this"
Code:
typedef struct
{
    var x;
    var y;
    STRING *funcName;    //The function pointer
} SPOT;

void callingFunction(SPOT *this) //your function
{
	STRING *tempStr = str_create("");
	str_cpy(tempStr, "this position x = ");
	str_cat(tempStr, str_for_num(NULL, this.x));
	str_cat(tempStr, ", and this position y = ");
	str_cat(tempStr, str_for_num(NULL, this.y));
	error(tempStr);
}

SPOT* setup_spot()  //a init routine
{
	SPOT* spot = sys_malloc(sizeof(SPOT));
	
	spot->x = random(100);
	spot->y = random(100);
	spot->funcName = str_create("");  //Set fn as func
	str_cpy(spot->funcName, "callingFunction");
	
	return(spot);
}

// empty prototype function
void PrototypeCallFunction(SPOT *this);

void main()
{
        random_seed(0);
	SPOT* spot = setup_spot();  //create SPOT
	
	PrototypeCallFunction = engine_getscript(_chr(spot->funcName));
	if(PrototypeCallFunction) { PrototypeCallFunction(spot); }
}




Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/