Aller au contenu

Photo

Dump variables


  • Veuillez vous connecter pour répondre
Aucune réponse à ce sujet

#1
Olblach

Olblach
  • Members
  • 175 messages
A function I wrote to dump variables, it only dump integers but it's easy to extend to other types (I didn't need them :P)
.
The output goes to logs.

void dumpvars(object oObj)
{
	int vcount ;
	int i;
	string vname ;
	int vtype ;
	
	vcount = GetVariableCount(oObj) ;
	PrintString(GetName(oObj) + ": " + IntToString(vcount) + " local variables.") ;
	for (i=0; i<vcount; i++)
	{
		vname = GetVariableName(oObj, i) ;
		vtype = GetVariableType(oObj, i) ;
		if (vtype == VARIABLE_TYPE_INT)
		{
			PrintString("variable: " + vname + " Integer: " + IntToString(GetLocalInt(oObj, vname))) ;
		}
		else
		{
			PrintString("variable: " + vname + " type: " + IntToString(vtype)) ;
		}
		
	}
}