Tutorial *136*

The builtin functions are called "etof" and "ftoe". "etof" returns the number of the edict/entity, while "ftoe" returns the edict/entity of a number.

These functions were added to the QSG standard by using the Enhanced BuiltIn Function System (EBFS) with the numbers #108 and #109. If you want to add these functions to your own engine, you should add the EBFS before.

In PR_CMDS.C add the following code anywhere before the builtin variables...



// 2001-09-25 New BuiltIn Function: etof() by Maddes  start

/*

=================

PF_etof



float etof (entity)

=================

*/

void PF_etof (void)

{

	G_FLOAT(OFS_RETURN) = G_EDICTNUM(OFS_PARM0);

}

// 2001-09-25 New BuiltIn Function: etof() by Maddes  end



// 2001-09-25 New BuiltIn Function: ftoe() by Maddes  start

/*

=================

PF_ftoe



entity ftoe (float)

=================

*/

void PF_ftoe (void)

{

	edict_t		*e;



	e = EDICT_NUM(G_FLOAT(OFS_PARM0));

	RETURN_EDICT(e);

}

// 2001-09-25 New BuiltIn Function: ftoe() by Maddes  end

... and to the EBFS data array add ...



	{ 108, "etof", PF_etof },	// 2001-09-25 New BuiltIn Function: etof() by Maddes



	{ 109, "ftoe", PF_ftoe },	// 2001-09-25 New BuiltIn Function: ftoe() by Maddes

Done.



 
Not logged in
Sign up
Login:
Passwd: