Author Topic: [tutorial] Trace(); is your friend  (Read 1430 times)

Ever wonder about why trace(n); exists?

NOTE: fixed by commenters

How to use trace();
Note that to open up the console, press the ~/` key on your keyboard.  It's probably below Esc or next to !/1.
http://blockland.live:8000/trace.mp4

What does it do?
When you use the trace(n); command in the console, where n is 0 for turning it off and n is 1 for turning it on, it writes to console.log whenever a function is called and what its arguments are.  This is great for debugging, such as if an addon fails to load, as it tells you why.



What can it look like?
http://blockland.live:8000/bla.mp4

« Last Edit: July 24, 2017, 01:37:02 AM by theviacom »

trace is only useful for getting various functions being called when you interact in the game. if an add-on fails or the game crashes, trace won't be useful, unless you know exactly when the crash will happen and have enough time to enable trace beforehand

trace is only useful for getting various functions being called when you interact in the game. if an add-on fails or the game crashes, trace won't be useful, unless you know exactly when the crash will happen and have enough time to enable trace beforehand

i should rephrase

i meant that you can figure out why an addon doesn't execute, such as if theres a syntax error

if there's a syntax error it will show up in the console automatically. you just have to scroll up

if there's a syntax error it will show up in the console automatically. you just have to scroll up

of course

trace is good to learn how things work and what is called when, an example being projectile collision, explosion creation, and damage checks. it also tells you in a way what parameters each function takes, so you can write code to correctly package or override the function


Default functions (functions that are declared in the engine) are not shown in trace.
Note that if you're using a TCP-heavy add-on (such as Blockland Glass), you should disable the add-on or the TCPObject that the addon uses, as the onLine() callback can contain large amounts of data, which can result in a buffer overflow (aka the game crashes)

Here's a trace tutorial also:

https://forum.blockland.us/index.php?topic=191941.0
Default functions (functions that are declared in the engine) are not shown in trace.
Note that if you're using a TCP-heavy add-on (such as Blockland Glass), you should disable the add-on or the TCPObject that the addon uses, as the onLine() callback can contain large amounts of data, which can result in a buffer overflow (aka the game crashes)
updated