Free Lua Scripting Interpreter Library For Delphi XE7 Firemonkey On Android And IOS
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 compiled 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 didn’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 has released an upgraded wrapper component for Lua 5.3 that allows you to run Lua scripts in Delphi XE7 Firemonkey. The wrapper which is called VerySimple.Lua uses the Lua static and dynamic libraries to enable the component on Android, IOS, Windows, and OSX. Between this component and paxCompiler you can now interpret Lua, Object Pascal, Basic, and Javascript on all four Firemonkey 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 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 and 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 is 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(LoadPath) + ‘” 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) + ‘”‘ {$IF 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, Win64, Mac OS X, iOS and Android. “Lua is a powerful, fast, lightweight, embeddable scripting language, it has been used in many industrial applications (e.g., Adobe’s Photoshop Lightroom), with an emphasis on embedded systems (e.g., the Ginga middleware for digital TV in Brazil) and games (e.g., World of Warcraft). Lua 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)
Example 1 – Simple usage
Example 2 – Extend Lua with own functions
helloworld.lua
Output:
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。