Debugging Lua

From CryWiki

Jump to: navigation, search

There are currently two ways to debug your lua code: printing out information or using the integrated debugger.

Using the Log Statement

Using the Log function will let you print out information to the console.

Insert a Log(x); statement wherever you want to print something in your lua code. Replace x with the variable you want to print. If you want to print a non-string variable, make sure to enclose it inside a tostring(x) statement.

For example, the following code prints "OnUpdate":

Log("OnUpdate");

Note
You have to set your log_verbosity to 3 or higher. This will allow you to see what's printed. In the console, type

log_verbosity 3

Printing a Table

Tables are common for holding structured information. To print the contents of a table, use the following:

for i,v in ipairs(table) do
     Log(v);
end

Using the Integerated Debugger

To use the integrated debugger, add a System.ShowDebugger(); statement to wherever you want the debugger to appear.

Personal tools