Talk:Data types

From modwiki

Jump to: navigation, search

Contents

As I said on the float page...

... I think this article should cover all normal datatypes without linking to them, as I don't think they are complicated enough to warrant their own pages. Opinions? --iceheart 03:45, 21 March 2006 (W. Europe Standard Time)

Data types on one page.

I suppose I could just finish adding them on seperate pages and then you could put them together and see if that's how you like them...alls fine with me.

Added link from Scripting Basics article

I added a section on varibles and another on functions. They're very rough draft. Infact, the functions section is just a header at this point. :)

I removed the attention template from this page as it's no longer orphaned.

--Rich 09:27, 21 March 2006 (W. Europe Standard Time)

For people wishing to add or check validity

The allowed types are based on the following function in Script_Compiler.cpp included in the Quake4 SDK:

 
idTypeDef *idCompiler::CheckType( void ) {
	idTypeDef *type;
	
	if ( token == "float" ) {
		type = &type_float;
	} else if ( token == "vector" ) {
		type = &type_vector;
	} else if ( token == "entity" ) {
		type = &type_entity;
	} else if ( token == "string" ) {
		type = &type_string;
	} else if ( token == "void" ) {
		type = &type_void;
	} else if ( token == "object" ) {
		type = &type_object;
	} else if ( token == "boolean" ) {
		type = &type_boolean;
	} else if ( token == "namespace" ) {
		type = &type_namespace;
	} else if ( token == "scriptEvent" ) {
		type = &type_scriptevent;
	} else {
		type = gameLocal.program.FindType( token.c_str() );
		if ( type && !type->Inherits( &type_object ) ) {
			type = NULL;
		}
	}
	
	return type;
}

There's also the following in Script_Program.cpp:

 
// simple types.  function types are dynamically allocated
idTypeDef	type_void( ev_void, &def_void, "void", 0, NULL );
idTypeDef	type_scriptevent( ev_scriptevent, &def_scriptevent, "scriptevent", sizeof( void * ), NULL );
idTypeDef	type_namespace( ev_namespace, &def_namespace, "namespace", sizeof( void * ), NULL );
// RAVEN BEGIN
// abahr
rvTypeDefString	type_string( ev_string, &def_string, "string", MAX_STRING_LEN, NULL );
rvTypeDefFloat	type_float( ev_float, &def_float, "float", sizeof( float ), NULL );
rvTypeDefVec3	type_vector( ev_vector, &def_vector, "vector", sizeof( idVec3 ), NULL );
rvTypeDefEntity	type_entity( ev_entity, &def_entity, "entity", sizeof( int * ), NULL );					// stored as entity number pointer
// RAVEN END
idTypeDef	type_field( ev_field, &def_field, "field", sizeof( void * ), NULL );
idTypeDef	type_function( ev_function, &def_function, "function", sizeof( void * ), &type_void );
idTypeDef	type_virtualfunction( ev_virtualfunction, &def_virtualfunction, "virtual function", sizeof( int ), NULL );
idTypeDef	type_pointer( ev_pointer, &def_pointer, "pointer", sizeof( void * ), NULL );
idTypeDef	type_object( ev_object, &def_object, "object", sizeof( int * ), NULL );					// stored as entity number pointer
idTypeDef	type_jumpoffset( ev_jumpoffset, &def_jumpoffset, "<jump>", sizeof( int ), NULL );		// only used for jump opcodes
idTypeDef	type_argsize( ev_argsize, &def_argsize, "<argsize>", sizeof( int ), NULL );				// only used for function call and thread opcodes
// RAVEN BEGIN
// abahr
rvTypeDefBool	type_boolean( ev_boolean, &def_boolean, "boolean", sizeof( int ), NULL );
// RAVEN END
 
idVarDef	def_void( &type_void );
idVarDef	def_scriptevent( &type_scriptevent );
idVarDef	def_namespace( &type_namespace );
idVarDef	def_string( &type_string );
idVarDef	def_float( &type_float );
idVarDef	def_vector( &type_vector );
idVarDef	def_entity( &type_entity );
idVarDef	def_field( &type_field );
idVarDef	def_function( &type_function );
idVarDef	def_virtualfunction( &type_virtualfunction );
idVarDef	def_pointer( &type_pointer );
idVarDef	def_object( &type_object );
idVarDef	def_jumpoffset( &type_jumpoffset );		// only used for jump opcodes
idVarDef	def_argsize( &type_argsize );
idVarDef	def_boolean( &type_boolean );

Lot's of work needs to be done in this area to improve our understanding and use of this awesome feature. It seems very likely that to some extent the scripting engine will enable a mod designer to implement their mod entirely in script. The benefits of this are huge mostly that they won't need to wait until an SDK is released to update their mod after a new patch version is released, and they won't need to use a seperate compiler since the game provides it.

Personal tools
Main