![firedacimagenotitle02 | Embarcadero RAD Studio Delphi C++Builder Blogs](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/06/firedac-image-no-title02.jpg?resize=1140%2C680&ssl=1)
Lua is with an emphasis on embedded systems (e.g., the Ginga middleware for digital TV in Brazil) and games (e.g., World of Warcraft). It is currently the leading scripting language in games and it has a deserved reputation for performance. To claim to be “as fast as Lua” is an aspiration of other scripting languages.
What’s new in v2.0?
- Lua 5.3.0 support (all header translations done from scratch)
- cross-platform – Windows 32 bit, Windows 64 bit, Mac OS X, iOS, and Android
- improved autoregister function – with the help of TRtti it registers only valid methods
- simplified callback with upvalues instead of pointer list
- package support
- examples included (VCL and FireMonkey).
Dynamic library vs. static library VerySimple.Lua uses the lua dynamic library if compiled for Windows, Mac OS X or Android and uses the static library if compiled for iOS (all libraries included).
Note the below sample code is available from the author of the library.
Automatic get/setters for properties, etc.
As the name implies: it is just a very simple Lua <-> Delphi binding. Feel free to add those functions by yourself.
Example 1 – Simple usage
1 2 3 4 5 6 7 8 |
uses VerySimple.Lua; begin Lua := TVerySimpleLua.Create; Lua.DoFile('example1.lua'); Lua.Free; end; |
Example 2 – Extend Lua with own functions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
uses VerySimple.Lua, VerySimple.Lua.Lib; type TMyLua = class(TVerySimpleLua) published function HelloWorld(LuaState: TLuaState): Integer; end; function TMyLua.HelloWorld: Integer; var ArgCount: Integer; I: integer; begin writeln('Delphi: Hello World'); ArgCount := Lua_GetTop(LuaState); writeln('Arguments: ', ArgCount); for I := 1 to ArgCount do writeln('Arg', I, ': ', Lua_ToInteger(LuaState, I)); // Push return values Lua_PushInteger(LuaState, 101); Lua_PushInteger(LuaState, 102); Result := 2; end; var MyLua: TMyLua; begin MyLua := TMyLua.Create; MyLua.DoFile('helloworld.lua'); MyLua.Free; end; |
![image28 | Embarcadero RAD Studio Delphi C++Builder Blogs](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/09/image-28.png?resize=750%2C389&ssl=1)
For more information or if you want to test this product, please check out https://github.com/Dennis1000/verysimplelua
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition