Concepts

Before diving into the concepts of LDT, if you need more information about the concepts of Lua itself, you are highly encouraged to refer to the Lua manual ( http://www.lua.org/manual/5.1/).

Interpreters

To run Lua scripts in LDT, you have to configure a least one Lua interpreter to run your code. To configure an interpreter you just need the path of the interpreter executable, then you can set interpreter arguments and set some environment variables. Interpreters are used by Run Launch Configuration to execute the code.

See below how to reference a Lua interpreter installed on your machine, and use it in LDT.

To open the Interpreters preference page go to Window > Preferences > Lua > Interpreters:

Then, press the Add... button to configure a new interpreter and fill in the fields as described here:

Once you press the Ok button, the created interpreter appears in the Interpreters page. The checkbox in front of each interpreter allows to check the default interpreter used in launch configurations.

Remote Debug

The Debugger of Lua Development Tools is based on the DBGp protocol, and the IDE implements a DBGp server.
To connect to this server, and begin remote/attach debugging, you need to use a DBGp Lua client.

DBGp Client

The DBGp Lua client is composed of two Lua files and can be downloaded here.
It runs on Unix-like OS and Windows (XP and later). It is written in Lua 5.1 and depends on lua-socket.
You can get Lua on http://www.lua.org/download.html and install lua-socket thanks to luarocks, or via your official OS repositories.

To use it, you must have these two files in your Lua path.
To begin the connection, you must execute this Lua code :

> local initconnection = require("debugger")
> initconnection(host, port, idekey)

which can be shortened like this:

> require("debugger")(host, port, idekey)

So, to debug any Lua script, you can do:

lua -e "require('debugger')("idehost","ideport");" MyApp.lua

or even just go with:

lua -e "require('debugger')();" MyApp.lua

if you want to rely on default values for the debug host and port (which should be 127.0.0.1:10000 if you didn't tweak any DBGP_* environment variable).

{{message|{{#if:{{{1|}}}|' console output'<BR>}}{{#if:{{{2|}}}|Some console output problems could happen because of buffer configuration. To force the stdout buffer to be flush at each call of print your should add this line io.stdout:setvbuf("line"); The full line should look like that :

<tt>lua -e "io.stdout:setvbuf('line'); require('debugger')();" MyApp.lua</tt>

}}|image=Idea.png|bgcolor=#def3fe|bdcolor=#c5d7e0}}

DBGp Server

The DBGp Server is integrated in LDT.
In order to accept incoming debug sessions, you must create a new Lua Attach to Application launch configuration, then launch it.

Go in Run/Debug Configurations....


Now you can start your debug session by clicking Debug. IDE will wait for an incoming connection from the debugger client, on the port you can see in the debug view. By default the port used is 10000, but if it is taken, another one may be used.

If needed, you can change the server port, in Window > Preferences > Dynamic Languages > Debug.

Paths configuration

In order to use propoperly remote debugging, you must care about paths. In our case, there are several kind of them to consider:

Project path

Project path is the one set using the '' Build Path > Configure Build Path ...'' UI. From there you can specify dependency to other project from current workspace. As a result, will enjoy completion and navigation between your project and the ones configured in Build Path.

Runtime path

Once your program is ready, you might try Remote debugging. You must ensure beforehand that all the projects you depend on are in Lua path. The configuration of this path is not detailed here since it is highly dependent on how you are managing paths in your own environment.

Execution Environment

An Execution Environment, which may also be referred to as EE, is file containing information about the environment where a Lua application could run. An environment is a set of libraries available to the application out of the box, as in Lua 5.1 or Corona SDK.

The idea is to provide a file capable to describe elements of this environment. All provided information allows LDT to offer better code completion, code navigation and documentation layout in LDT.

{{{imgwidth
The Execution Environment for the Lua standard library is not yet bundled with LDT, but we have made it available here. You'll definitely want to install it!

Manage Execution Environments

To find preferences related to EE, go to Window > Preferences > Lua > Execution Environments and you will have following interface.

From there, is it possible to add an EE to current workspace by pressing Add, then select an Execution Environment.

The EE is now available.

Once you have manage to install Execution Environments in your workspace, it is time to use them in a project. Right click a project and select Build Path >> Add Libraries ....

You will have to choose between several libraries types, choose Lua Execution Environment.

You can now choose among installed EEs and press OK.

It is now linked to selected project.