Author Topic: How do i get the code of a function  (Read 910 times)

so lets say that i made a function called bacon();
I want to get the code from bacon and add stuff to it, then save the function
how would i do that?
like

function bacon(){
commandtoserver('messagesent',"want bacon");
}

then get the code of bacon to add stuff to it

function bacon() {
commandtoserver('messagesent',"I think i would");
call bacon(); //or parent::bacon?
}

and the out put would be:

Player: i think i would
Player: want bacon

would i use the parent of bacon to do this?

Code: [Select]
package foo
{
function bacon()
{
commandToServer( 'MessageSent', "I think i would");
parent::bacon();
}
};

activatePackage( "foo" );

-snip-

I'm pretty sure that's not what he was asking for,

To call a function just do the functions name and args
Like so:

bacon();

That would call the function "Bacon", and make it do whatever is inside the function.






Keep in mind to stay away from naming TWO functions the same thing.

I'm pretty sure that's not what he was asking for,

To call a function just do the functions name and args
Like so:

bacon();

That would call the function "Bacon", and make it do whatever is inside the function.

Calling a function conditionlessly from within the function itself will yield an infinite loop.

Calling a function conditionlessly from within the function itself will yield an infinite loop.

Wait, he is calling the function from INSIDE the function itself?

Wait, he is calling the function from INSIDE the function itself?
i want to add to the function
like make calling the bacon function super admin only?

i want to add to the function
like make calling the bacon function super admin only?
see ports answer, using packages and parents.

Keep in mind to stay away from naming TWO functions the same thing.

really? you can't overload in torque? (never tried it)

really? you can't overload in torque? (never tried it)
You will overwrite it. He just said that because he wanted to warn him it would 'break' whatever thing he overwrote.

can i at least get the code of a function?
like

announce(getcode('messagesent'));
would announce the messagesent code?

can i at least get the code of a function?
like

announce(getcode('messagesent'));
would announce the messagesent code?
not possible.

The closest way you can do this is by trace(), but that only says when functions are called, and what functions are called by that function.

The closest way you can do this is by trace(), but that only says when functions are called, and what functions are called by that function.

Mentions practically nothing anyway.