Poll

Who is the best scripter that can teach me?

Danny Boy
Truce
Xalos
jes00

Author Topic: My chatbot is not working  (Read 8143 times)

Quick question, they did not tell me this in the tutorials, but what does %this does?

In what context?
%this can be everything

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.

%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: [Select]
//Yes, it's not in a package, it's just as an example.
function GameConnection::spawnPlayer(%this) {
   Parent::spawnPlayer(%this);
}
%this in this example refers to the GameConnection (aka the client).

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.
Beat me to it, haha.

%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.
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.

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.

It doesn't have to be there, i can do gameConnection::autoAdminCheck(%lol), but it's proper practice.

It doesn't have to be there, i can do gameConnection::autoAdminCheck(%lol), but it's proper practice.

Indeed.

Code: [Select]
==>function scriptObject::dummy( %hello ) { echo( %hello ); }
==>scriptObject::dummy( 5 );
5

%this is just like %client but instead doesn't work for your client. %this represents the ID of the object.

I think so anyway.

It doesn't have to be there, i can do gameConnection::autoAdminCheck(%lol), but it's proper practice.

ok.
So, its a variable that is server sided

%client
is client-sided!

Got it.

Thanks

ok.
So, its a variable that is server sided

%client
is client-sided!

Got it.

Thanks

No, its a variable for the object let me explain:

Say we package fxdtsbrick::onplant(%this)

%this would be the brick

Say i do some client sided thing:

Function simObject::doDump(%this)
{
    %this.dump();
}

Now we can do serverConnection.getControlOb ject().doDump();

in this case, %this would be our control object.

Another: serverConnection.doDump();

%this would be our serverconnection object, etc, etc.

ok.
So, its a variable that is server sided

%client
is client-sided!

Got it.

Thanks
No, that's not correct.

The variable can be named anything, it could be named %lkgjlkdb["asdfasdf"] for all torque cares. It represents the instance of the class that the function is being called on.

For example:

%a.doStuff();
the first argument in that function will be set to %a.

it could be named %lkgjlkdb["asdfasdf"]
ehhhh torque wouldn't accept that as an argument but the gist of what you say goes through

ehhhh torque wouldn't accept that as an argument but the gist of what you say goes through
it actually will, it's an array (which you probably know) which would turn out as this:
%lkgjlkdbasdfasdf

it actually will, it's an array (which you probably know) which would turn out as this:
%lkgjlkdbasdfasdf
YOu can even use any charachter that blockland supports, like €£¥#%^*+=?, and as long as you put those characters in array brackets, it will work. you can even use spaces.

Function inputs can also be used to automatically set global variables. ie
Function setGlobal($stuff, $otherstuff){}
Will set the two inputs to the global variables stuff and otherstuff, respectively.

Although I'm not sure if you can do things like
Function createarrayinarguments(%a, %array[%a]), can anyone tell me if that's valid? Or try it?

it actually will, it's an array (which you probably know) which would turn out as this:
%lkgjlkdbasdfasdf
Torque doesn't accept arrays as arguments to functions.