This

Started by Construed, Fri 20/04/2012 19:19:56

Previous topic - Next topic

Construed

I'm wondering what all functions are compatible with:

This.

like This.room, This.WalkSpeed, This.player etc...
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

Icey

I found this in the Manuel.


this
There are two uses for the this keyword.
1. Accessing members of the current struct

When you are creating custom structs, you use the "this" keyword inside member functions to refer to the current struct. For example:

Suppose you had this in your script header:

struct MyStruct {
  int myValue;
 
  import function MyMethod();
};

Then, in your main script, you could put this:
function MyStruct::MyMethod()
{
  this.myValue = 5;
}

The MyStruct::MyMethod tells AGS that you are defining the function MyMethod which belongs to the struct MyStruct (the :: operator means "belongs to").
The code above will mean that when the MyMethod function is called, it sets the myValue variable to 5.

2. Declaring extender functions

Please see the Extender functions page for details.

Construed

Thanks Icy, Very intuitive explanation :D
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

Atelier

Grim you can press F1 whilst in the editor to see the manual.

Icey


SMF spam blocked by CleanTalk