| Blockland Forums > Modification Help |
| My chatbot is not working |
| << < (19/23) > >> |
| Deoxys And One Noob:
Quick question, they did not tell me this in the tutorials, but what does %this does? |
| Blocki:
In what context? %this can be everything |
| Ipquarx:
He means in functions, like: class::method(%this, %args0, %args1.., %argsn), in which case %this is the instance of class that the method is being called upon. |
| Daenth:
%this is often used as a variable for what the function is affecting. It has no effect on the function what so ever, it's simply for convenience. You could replace it with %client and it'd be the same thing. Sounds odd to explain, but it's used for stuff like this: --- Code: ---//Yes, it's not in a package, it's just as an example. function GameConnection::spawnPlayer(%this) { Parent::spawnPlayer(%this); } --- End code --- %this in this example refers to the GameConnection (aka the client). --- Quote from: Ipquarx on May 04, 2012, 05:31:45 PM ---He means in functions, like: class::method(%this, %args0, %args1.., %argsn), in which case %this is the instance of class that the method is being called upon. --- End quote --- Beat me to it, haha. |
| Ipquarx:
--- Quote from: Daenth on May 04, 2012, 05:32:11 PM ---%this is often used as a variable for what the function is affecting. It has no effect on the function what so ever, it's simply for convenience. --- End quote --- If a function is defined for an object/class, then the %this argument (whatever you name it) has to be there. If you want an argument in the function, there should be %this and then your arguments. It's how the engine works. It's not just for convenience. |
| Navigation |
| Message Index |
| Next page |
| Previous page |