Pointer (ZScript)

From ZCWiki
Jump to: navigation, search

// Defines Pointers, each type, for each class, and namespace

Special Pointers and Members

Pointers are used to associate values between a given class, or namespace, and the properties of that object.


The this pointer is used to define members relating to FFCs, and is also used for some other classes, such as items. As an example, you may use 'this' as a valid pointer to read, or write to members of the itemdata family, when making 'item scripts'.

this, FFC Scripts

When use din an FFC script, the 'this' pointer refers to all the variables for the ffc class. Thus, X, Y, Data, and all other variable properties associated with that individual FFC, are referenced with the 'this' pointer.

Example Use:

	// //Attach to an FFC. 
	ffc script MyFFC{
		void run(){
			this->Data = 10;//  //Sets the combo used byt he FFC to Combo ID 10.
			this->X = 30;//  //The X-coordinate of the FFC will be '30'.
			this->Y = 110;//  //The Y-coordinate of the FFC will be '30'.

Because an FFC set to Combo '0' will not run scripts, using 'this->Data = 0' is an efficient method of clearing the FFC slot for use with another script.

this, Item Scripts

When used in an 'item script', the 'this' pointer refers to the itemdata structure. You may read, or modify the variable properties (members) of the itemdata class, using a 'this' pointer in item scripts.

Example Use:

	// //Attach to an item in the item editor. 
	item script ModItem {
		void run(){
			this->UseSound(50);//  //The item will generate sound 50 when used, overriding the normal settings.
			this->UseSprite(2);//  //The item will use sprite 2 when used, overriding the normal settings.