How to use trace

Author Topic: How to use trace  (Read 5473 times)

What Is Trace?

Purpose
Use the trace function to enable (or disable) function call tracing. If enabled, tracing will print a message every time a function is entered, showing what arguments it received, and it will print a message every time a function is exited, showing the return value (or last value of last statement) for that function.

Syntax
Trace(enable); enable – A boolean value. If set to true, tracing is enabled, otherwise it is disabled. (trace(1); or trace(0);)

Returns
No return value.

Definition from Garage Games.


Example 1

Now you may be thinking, "Elm, I still don't know what to do!". Well let me show you a few examples below.

Now let's say we want to know what happens when a player jumps. Well, start up a server and enable tracing, jump, then disable it really fast. Now open up your console and you should see a lot of junk, scroll up till you see "Entering Jump(1)", it should look like so:



Everything having to do with jump I highlighted, and I will explain to you below.



So since we are the host, we can see server sided things going on. The server sided function that gets called on when a player jumps is armor::onTrigger. Not going to go too much into detail on what it does, how it works, etc.

The client sided function that gets called as you can see is Jump(boolean). You can see what arguments it takes and what it returns;



Example 2

Let's try another example, moving forward! So what happens when we move forward? I'll show you. Once again, be at your own server (don't have to be, but it makes looking through your console a bit easier), enable tracing, move forward a bit, then disable it quickly.

Now you should see a lot of stuff again which will look somewhat like this:



Notice the selected area:



That is the function that gets called, the arguments it took, and what it returned when you moved forward.



Also

When tracing certain functions, there may be a lot of stuff that goes on between the entering of the function and the leaving of the function so try and know what you are looking for.

I wrote this because there are a lot of questions users ask that if they knew how to trace, they could answer themselves. Any questions or concerns, drop a message below.
« Last Edit: April 15, 2012, 11:00:53 PM by elm »

This is an amazing tutorial...
I've just never have seen someone ask how to use trace before...

This is an amazing tutorial...
I've just never have seen someone ask how to use trace before...

I wrote this because there are a lot of questions users ask that if they knew how to trace, they could answer themselves. Any questions or concerns, drop a message below.

This entire tutorial, and you never explain the only thing that people who will probably need the tutorial will want to know:  Hit the squiggly key, type trace(1); into the white box that shows up, and hit enter.

This should be stickied; it can be quite helpful for beginning scripters.

This entire tutorial, and you never explain the only thing that people who will probably need the tutorial will want to know:  Hit the squiggly key, type trace(1); into the white box that shows up, and hit enter.
This.

This should be stickied; it can be quite helpful for beginning scripters.
This.

Lol i fixed it already.

You should mention in the OP that it's easier to find what you are looking for if you disable as many add-ons as possible. Especially add-ons such as autobridge that have a continually occurring tick

SHOULDN'T DIE

*BUMP*

Syntax
Trace(enable); enable – A boolean value. If set to true, tracing is enabled, otherwise it is disabled. (trace(1); or trace(0);)
I'm still fairly certain that a person that would need this tutorial could not follow this.