First of all, download LuaEdit here,
install it and start it. (If LuaEdit is already installed, simply start it)
Then, we need to create a new project which will contain a lua script file in it.
Once the new project is created, save it under [Tutorial]\Bin\Simon.lpr and save its lua script file
under [Tutorial]\Bin\Simon.lua where [Tutorial] represents the path where you unzipped this
tutorial. We need to do so to be able to set the "Initializer" property. This "Initializer"
property is in fact the path of a dll file wich MUST export the following function:
- Delphi: LuaDebug_Initializer(L: PLua_State): Integer; cdecl;
- C/C++: int LuaDebug_Initializer(lua_State *L);
This function will be called right before the execution of the script and its use may
vary from a project to another. In other words, this is a call back function in which you
may do anything useful with/without the Lua state before any scripts have been executed.
Only lua script files contained in a project can benefit of the "Initializer" property
since this property is set in the project settings. In our example in this tutorial, we will
assign the full path of [Tutorial]\Bin\simon.dll file. This file exports the function discussed
above to register functions to the Lua environement. Once this property is set, save the project
again and let's get ready to talk about code.
Hints:
- To create a new project, click on the menu Files/New/Project
- If you can't find the Project Tree window, this may be because it's hidden.
To show it, click on the View/Project Tree menu.
- To set the initializer property of a project, right click on the project
file in the project tree, and click on the Project Settings menu. In the
Project Settings dialog, select Debug tab. Specify the path of a valid dll
file and press Ok when done.
- You may want to change the project name to Simon in the project settings.
Changing this property has no effects but may help you when working with
LuaEdit.
|