Free Lua Scripting interpreter Library for Delphi XE7 Firemonkey on Android and IOS

Source: Internet
Author: User
Tags lua

http://www.fmxexpress.com/free-lua-scripting-interpreter-library-for-delphi-xe7-firemonkey-on-android-and-ios/

http://blog.spreendigital.de/tag/delphi/

http://blog.spreendigital.de/2015/02/18/verysimple-lua-2-0-a-cross-platform-lua-5-3-0-wrapper-for-delphi-xe5-xe7/

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 Co Mpiled for IOS (all libraries included).

Unit tests < excuse type= "lame" >this binding is based on my now 6 year old Lua 5.1 Delphi binding, and I di DN ' t had time for writing (updated) unit tests</excuse>.

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.

Developer Dennis D. Spreen have released an upgraded wrapper component for Lua 5.3 that allows I to run Lua scripts in De Lphi XE7 Firemonkey. The wrapper which is called Verysimple.lua uses the Lua static and dynamic libraries to enable the component on Android, I OS, Windows, and OSX. Between this component and paxcompiler you can now interpret Lua, Object Pascal, Basic, and Javascript in all four Firemon Key platforms at runtime. Blizzard uses LUA as the scripting language in World of Warcraft as one example of where people use Lua. There is some a sample code for using the wrapper on the blog post itself. There is also more sample code for using Verysimple.lua and interpreting Lua scripts in both FMX and VCL on Google code an D in the download. This Lua scripting interpreter component should also work with Appmethod. It is free and full source code is available. A Dynamic Library is used on Android, OSX, and Windows. A Static library is used on IOS. I looked through the code and here are A snippet for how it loads the dynamic Lua library:

{$IFNDEF Staticlibrary}

Check if Library exists if not fileexists (LoadPath) then raise Elualibrarynotfound.create (' Lua Library ' + quotedstr (L Oadpath) + ' not found ');

Try to load the library Libraryhandle: = LoadLibrary (PChar (LoadPath)); If Libraryhandle = 0 Then raise Elualibraryloaderror.create (' Failed to load Lua library ' + quotedstr (loadpath) + ' "' {$I F defined (POSIX)} + (String (dlerror)) {$ENDIF});

Lua_newstate: = getaddress (' lua_newstate '); Lua_close: = getaddress (' Lua_close ');

http://blog.spreendigital.de/2015/02/18/verysimple-lua-2-0-a-cross-platform-lua-5-3-0-wrapper-for-delphi-xe5-xe7/

Verysimple.lua is a Lua 5.3 binding for Delphi Xe5-xe7 which automatically creates OOP callback functions for Win32, WIN6 4, Mac OS X, IOS and Android. "Lua is a powerful, fast, lightweight, embeddable scripting language, it had been used in many Industria L applications (e.g., Adobe ' s Photoshop Lightroom), with a emphasis on embedded systems (e.g., the Ginga middleware for D Igital TV in Brazil) and games (e.g, World of Warcraft). Lua was currently the leading scripting language in games and it had a deserved reputation for performance. To claim to being "as fast as Lua" is a aspiration of other scripting languages. "

Download Current version at Google Code

What's new in v2.0?

    • Lua 5.3.0 Support (all header translations do from scratch)
    • Cross-platform–windows, Windows-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)

Example 1–simple Usage

12345678910 uses verysimple. Lua; begin Lua : = tverysimplelua. Create; Lua. Dofile(' Example1.lua '); Lua. Free; end;

Example 2–extend Lua with own functions

12345678910111213141516171819202122232425262728293031323334353637 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< Span class= "crayon-h" > := 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;

Helloworld.lua

1234567 Print("Luadelphi Test"); P1,p2 = HelloWorld(1,5,) print "Results:"; print (p1); print (p2);

Output:

1234567891011 luadelphi Test Delphi: Hello World Arguments: 3 Arg1: 1 Arg2: 5 Arg3: Results: 101 102

Free Lua Scripting interpreter Library for Delphi XE7 Firemonkey on Android and IOS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.