UPDATE 1 (6th Feb 2012)
- All known bugs have been fixed
- Packages have been added (to both LKSL and Lua4Delphi) for Delphi 2010 and XE
- A functional FireMonkey demo has been added to Lua4Delphi (requires XE2, for obvious reasons)
Now the original article…
The first phase of Lua4Delphi is now available for you to download and use with Delphi 2010, XE and XE2.
Phased Release
I would like to point out that this is a phased release, meaning that it is presently incomplete, and will have intense updates (at least once daily) over the next month, and will be updated regularly indefinately!
Presently you can do everything demonstrated in the first Implementation Samples article. A bug was identified during the Launch Webinar, where-by it is possible that you will be unable to read values returned by a Lua method executed from Lua. This bug is known, and is at the very top of my list (will be addressed in the first update on 6th Feb 2012).
Also on the sheet for the first update is to reintroduce all features temporarily removed due to needing changes related to the recent significant Interface overhaul. The features were removed because they would prevent the package from compiling properly… but will be put back in for the first update!
Presently there are only packages for Delphi XE2, but XE and 2010 packages will be added in the first update as well!
A comprehensive roadmap and timeline will be posted on the Lua4Delphi website (which itself will be launching very soon too).
I apologize for the delay in getting this released. Originally the intent had been to release it on Feb 1st, but a fundamental necessary change made that impossible (as this change broke the Interface, which would have rendered it entirely incompatible with any existing implementation).
Weekly Webinars
For at least the next 4 weeks, I will be holding webinars each week, three per scheduled day to cater to different time-zones.
The next webinars will be:
Sunday Feb 12th, 00:00 UTCsession endedSunday Feb 12th 12:00 UTCcancelled due to completing next update. Please attend the 21:00 UTC session
Sunday Feb 12th 21:00 UTCsession ended
Sunday Feb 19th, 00:00 UTCSunday Feb 19th, 12:00 UTCSunday Feb 19th, 21:00 UTC
Due to me suffering the flu at this time (17th Feb 2012), I’m not going to be able to host a webinar this week. Seriously… I can’t even talk, and you wouldn’t be able to understand a word I attempt to say right now. I’ll reschedule the webinar as soon as my voice returns and this incessant coughing ends.
The next set of webinars will demonstrate the most powerful feature of Lua4Delphi, and the single most demanded feature of any scripting language in terms of Delphi development! It is very important that you be there, as this will change the way you think about programming for the rest of your life!
No prior registration is required! The URL will be posted on here (as well as Twitter and Google+), and will be valid for all webinars (the URL will of course be inactive between webinars).
Recorded videos, written guides and documentation will also provide an easy way for people to quickly learn how to leverage Lua4Delphi. It has been designed to provide absolute simplicity for those using it!
Bug Reporting
Until the Lua4Delphi website goes live (complete with a simple Bug Reporting facility), please report bugs to me via the usual channels: this blog, Skype, Twitter, Google+, e-mail.
Please provide as much information as possible about the bug you encounter (including source code where appropriate)
Downloading Lua4Delphi
Lua4Delphi depends on the first portion of the LaKraven Studios Standard Library, so both are required!
The LKSL is aailable at:
URL: http://svn.lakraven.com:81/svn/LKSL
Username & password are both anon
Lua4Delphi is available at:
URL: http://svn.lakraven.com:81/svn/Lua4Delphi
Username & password are both anon
Installation
First load LKSL\Packages\[Delphi Version]\LKSL.dproj, right-click on the project in the Project Manager and press Install. Note that this package does not presently contain any components. Also note that you can ignore (For now) LKSL_IDE.dproj, as this is not yet in use!
Now that the LKSL is installed, we can install Lua4Delphi itself!
Load Lua4Delphi 2\Packages\[Delphi Version]\Lua4Delphi.dproj, right-click on the project in the Project Manager and press Install.
Please note that the Lua4Delphi package currently only installs a single component on the Pallet: TL4D51Static (Static linked, Lua 5.1).
The various Lua DLLs for the supported platforms are contained in the \Bin\[platform]\[configuration] folders, and the Lua5.1.dll file (for either Win32 or Win64 as appropriate) will need to be available in the same folder as your Lua-integrated executable. For Mac builds you’ll also need to deploy the .dylib, .so, and .a files, but please keep in mind that MacOSX support is largely untested at this stage! Expect to encounter bugs on OSX for the moment!
Thank you!
I just want to thank everyone for their patience up to this point! I know this has taken a long time to release… I also know that what has been released thus far is a fairly small portion of the overall suite! The daily updates will address that!
Anyway, I hope you enjoy Lua4Delphi, and the new wealth of possibility it introduces to your Delphi-made software!

February 5, 2012 at 7:29 am
Congratulations!
February 5, 2012 at 1:13 pm
Great, Congrats!
I’m anxiously awaiting the D2009 packages, for integration/implementation with another project, but ‘no worries, no hurries’, there’s no time-pressure
February 5, 2012 at 8:36 pm
Congratulations Mate. I bet it feels good to finally get this thing out the door.
February 6, 2012 at 2:54 am
I am having a problem with installation. Downloaded ok, and installed LKSL ok into XE2(Update 3) and can build Lua4Delphi package ok but get the following error on right mouse click install Luw4Delphi.
“Package …/Lua4Delphi160.bpl can’t be installed because its was created with a different version of Delphi or CBuilder”
I deleted all the dcu’s and bpl that came with the download and rebuilt everything, still same problem
Any Ideas ?
February 6, 2012 at 7:09 am
There’s absolutely no reason I can think of why that should ever happen! The package was assembled in XE2 Update 3, you compiled it in XE2 Update 3…. it should install just fine!
Really does sound like a Delphi problem
You don’t have more than one version of Delphi installed do you?
February 6, 2012 at 8:15 am
As I have had the same problem yesterday evening (and gave up for some sleep), I guess that it has something to do with loading the required dll. As the dll is linked staticly, it has to be loaded in the IDE when the package is loaded. Will investigate further, but perhaps with this information someone has a clue?
February 6, 2012 at 9:00 am
Ah yes… I found that I had to put the Lua DLLs in Delphi’s BPL folder to get the package to install properly!
February 6, 2012 at 8:23 am
Additional hint: I get an error when I start Lua5.1.exe from the command line, while Lua5.2.exe starts fine. Perhaps a broken lua5.1.dll?
February 6, 2012 at 9:01 am
I don’t appear to have this issue! Will do a clean check on the package (didn’t have time prior to launch) and iron out any remaining issues!
February 6, 2012 at 8:26 am
Problem solved! Downloading the lua5.1.dll from http://luabinaries.sourceforge.net/download.html did the thing.
February 6, 2012 at 9:01 am
Yep, this works…. except the Lua 5.1 DLL I provided was LuaJIT 2!
February 6, 2012 at 9:06 am
I actually wondered about the size difference. So perhaps there is something missing when I try to load the LuaJIT dll? Starting Lua5.1.exe didn’t work either.
February 6, 2012 at 10:28 am
I’ll look into this shortly after I’ve solved the known bug (reading return values correctly)
February 6, 2012 at 9:41 am
The problem seems only related to the 32 bit version of the jit dll. The 64 bit Lua5.1.exe can be started flawlessly.
February 6, 2012 at 10:27 am
Have you tried the 32bit executables from both the Release and Debug folders? Any difference between the two (as in does either one of them work for you)?
February 7, 2012 at 4:22 am
Confirmed, replacing the lua5.1.dll from a different source fixes the install problem. Looks like there is a problem with the lua dlls in the svn repository.
February 7, 2012 at 7:55 am
I’ve updated the SVN with the correct Lua5.1.dll files for Win32!
February 6, 2012 at 8:38 am
I cannot access svn ? server is down ?
February 6, 2012 at 9:01 am
Server is very-much up and running. Is your network blocking access on port 81 by any chance?
February 6, 2012 at 9:25 am
It’s a possibility. unfurnatly, I will not have respond from my sysadmin, the helpdesk is outside and I cannot contact them.
I will try at home this evening
February 6, 2012 at 10:31 am
Let me know if it makes the difference!
February 8, 2012 at 7:31 am
Hi
It was :81… so I can’t use svn at work
If you can… use SourceForge or an other hosting with standard Internet access.
February 8, 2012 at 7:48 am
I’m going to reconfigure the SVN server soon to support Port 80… and I’m also working on a system called “RepoZip” so I can provide a “Download as ZIP” button for those who don’t wish to use SVN.
February 6, 2012 at 5:21 pm
My congrats for Lua4Delphi release … and having the live webinars demos/sessions is definitely great !
Anyway, for the ones having no chance to attend the sessions (including me) hopefully some recordings will be made available later. Keep up the good work … and don’t forget to “flood” the demos folder with more & powerful example since now it looks a a bit too “thin” (for all the goodies that been announced).
February 6, 2012 at 5:44 pm
Yes, the more advanced demos will be added as I put the features back in (remember, I have stripped it apart and am putting it back together to support Lua 5.2 as well as 5.1).
Even with just the features available publicly today, it is a very usable (easily implemented) scripting solution
February 7, 2012 at 1:13 pm
A bit off-topic (also tweeted about it) … but it might be very good news in context of Lua usage
Lua chosen by Wikipedia as a new template scripting language
https://en.wikipedia.org/wiki/Wikipedia:Wikipedia_Signpost/2012-01-30/Technology_report
Wikimedia to use Lua for production-ready replacement of MediaWiki-markup templates
http://www.mediawiki.org/wiki/Lua_scripting
PS: Any chance to post the recordings of the Lua4Delphi webinars (protip: I’ll pick Vimeo instead of YouTube for video hosting) ?
February 7, 2012 at 3:21 pm
Got videos in the pipeline, but rolling out the rest of the system takes priority at this stage!
February 8, 2012 at 8:02 am
First excuse me for poor english (I’m french speaking)
I still havn’t success install with XE2 (path ?) at home : I will try again
It seems success install with XE (at work) after changing ‘F:/…’ and ‘E:/…’ paths in package source.
I will try to port my application with this component :
I use Lua in Threads, so I have implemented a “Synchronize” virtual Method at my base Lua component, I suggest you to do the same (I’m not very specialist with threads… if you have some advice… I take!) and call the OnLuaError() event through this method (I also added OnLuaWarning, OnLuaDebug at base component)
I also added with same philosophy :
- OnPrint(), to capture print() function of Lua
- OnProgress(Sender : TObject; Caption, Msg : string; PercentDone : integer; Tag : integer) and progress() function in Lua
- OnGetkillRequest(Sender : TObject; var Kill : boolean), and script kill feature through hook
- a Lua sleep() function, implemented with TEvent
The above modification allow me to use scripts in single thread or multi-thread (with a derived class having more thread support) without changes
Best regards
February 8, 2012 at 8:13 am
Wait… Are you telling me the packages are storing the FULL PATH to each file? They’re not supposed to be! I’ve specified relative paths in the package’s source!
February 8, 2012 at 9:13 am
yes
I have sucess installed XE by changing absolute paths
I will try XE2 this evening (if I have time)
February 8, 2012 at 9:14 am
I’ve updated the SVN to switch the paths to relative (as they were supposed to have been originally).
February 8, 2012 at 10:18 am
I also suggess to add Sender : TObject in all events
February 8, 2012 at 12:49 pm
I can place Sender: TObject on the Exception events, for sure, but I absolutely cannot do that on methods exposed to Lua.
February 8, 2012 at 11:23 am
Other stange : I use XE and DCU appear in XE2 directory
February 8, 2012 at 12:49 pm
Updated SVN to fix this issue
February 8, 2012 at 12:42 pm
I also have needed to add source path of LKSL and Lua4Delphi in my project options.
February 8, 2012 at 12:50 pm
Yes, that goes without saying no matter what package you install…. to use the components you always have to add the source folders to the Search/Library Path!
Pingback: [LUA] Datei mit Handle auslesen - Delphi-PRAXiS
February 8, 2012 at 1:03 pm
Many thanks for the quick reaction time
Other questions
What do you mean by Wrappers (directory empty) and TL4DEngineMember ?
I’ve developped some ‘plugin’, ‘module’, ‘library’ : don’t realy choose what name for, that add some functions to Lua scripts. Example :
type
TLuaShellAccessPlugin = class(TLuaPlugin)
protected
function RegisterModules(Lua : TLua; SingleInstance : boolean = true) : boolean; override;
published
function CmdLine(LuaState: TLuaState) : Integer;
function ParamCount(LuaState: TLuaState) : Integer;
function ParamStr(LuaState: TLuaState) : Integer;
function FindCmdLineSwitch(LuaState: TLuaState) : Integer;
end;
that add command-line access. It is a Wrapper ? It is derived from TL4DEngineMember ?
NB: I don’t see why you can’t pass ‘self’ parameter for Sender in a OnLuaError event ?
February 8, 2012 at 1:21 pm
I can pass “Self” for OnException and OnLuaError… but not for when Lua invokes a Delphi-defined method.
“Wrappers” are units which register entire Delphi types (Classes, Records, Arrays etc.) with Lua… so Lua can understand things like TButton etc.
The folder is empty at the moment because I have to drop back in things like TL4DTable and TL4DTableValue (both of which I have temporarily removed while adding Lua 5.2 support and changing the interface to support both).
It’ll all become clear on the next webinar, where I’ll demonstrate all this.
Don’t pass around TLuaState! Lua’s API passes around PLuaState (a POINTER type)!
February 9, 2012 at 1:42 pm
Dear
I have adapted your component for my use, but I need some modification at core level. Can I send you my request (mail or post in this blog) ?
Think that some of theyse feature could be used by other users…
Best regards
NB : you can delete this post and reply me by email…
February 10, 2012 at 3:24 pm
I got your e-mail and will take a look shortly. For the moment I’m trying to catch up on lost time (courtesy of my car being “written-off” this week)
February 8, 2012 at 7:06 pm
When trying to execute a lua function from inside Delphi (as demonstrated in your Samples Part I) the returning value is available only after the second call (I am pressing a TButton). The button code is:
L4D51Static1.InjectLuaFile(ExtractFilePath(Application.ExeName) + ‘test.lua’, True);
with L4D51Static1.Globals['LuaAdd'].CallFunction([5,10]) do
begin
ShowMessage(Value[1].AsString);
CleanUp;
end;
February 10, 2012 at 4:02 pm
Yes, I am tracking this issue now… but it is quite difficult to reproduce with accuracy! In some tests, it has worked perfectly, in others… same issue you’re getting.
I’m fairly sure this is an INLINE issue of some kind, but it has been quite illusive.
Can you please provide the Lua portion of this code, or are you literally using the same code as in the sample article?
February 9, 2012 at 12:00 am
Congrats!, I’ll give it a try!
February 10, 2012 at 1:52 pm
Seems to have a bug with <>
A defined method raise an exception while similar code with <> run fine
February 10, 2012 at 1:53 pm
Seems to have a bug with ‘Managed “Unbound” approach’
A defined method raise an exception while similar code with ‘Managed “ObjectMethod” approach’ run fine
February 10, 2012 at 2:27 pm
Problem found… committing fix to SVN now! Thanks for reporting (catching up on all messages, so please be patient with me)
February 10, 2012 at 3:12 pm
No problem… did you received my changes suggestion mail ?
I’m still porting my code…. have you an example on how to define “User defined types” with L4D ?
February 10, 2012 at 3:24 pm
The very next update introduces the prototype for User-defined Types (or “Wrapper Types” as I call them)…. just requires some ironing out as the latest changes have introduced a few bugs!
February 14, 2012 at 3:32 pm
I moved the ‘FLua field’ of ‘TL4DMethodStack’ from private to public
I make a test to throw error in a delphi defined function with the syntax :
AStack.FLua.Lua.luaL_error(‘Test error’);
Seems working…
A good idea will be to add some ‘error’ methods to ‘TL4DMethodStack’ and move back to private the FLua field (an other idea is to add a public ‘Lua’ property)
February 14, 2012 at 3:53 pm
This is an artefact from some refactoring, where some Stack Managers were changed from Class to Record (in order to provide automatic memory management).
The next update will provide ALL Stack Managers with an additional property “Engine”, which exposes “FLua” that way.
So after the next update is committed to the SVN, you’ll be able to do
AStack.Engine.Lua.luaL_error(‘Test error’);
Cheers for pointing this out to me
February 17, 2012 at 7:30 pm
Yet another bit offtopic, but LDT based on Eclipse seem pretty helpful for developing scripts in Lua http://www.eclipse.org/koneki/ldt/
Any other suggestions?
February 17, 2012 at 8:15 pm
“Decoda” is perfect, as it’s also a Lua debugger. Normally I just use Notepad++
February 18, 2012 at 10:03 am
Waiting for next webinar … I wish you a speedy recovery
February 18, 2012 at 11:52 am
Thanks!
March 2, 2012 at 10:17 am
Hi
What about updates ??
seems to be very long… you said “intensive”…
an idea : change svn port (for those as me that cannot use 81), and allow collaborative work….
March 2, 2012 at 10:00 pm
Delay is due to my having very bad flu, while trying to complete some client work (keep in mind that’s what pays my bills around here).
I agree I need to take a look at the SVN server setup… that said, it does support port 8080 (which is the alternative port for 80 and SHOULD be unlocked on any network per the ISO standard)
I do not want other parties modifying my codebase directly as the codebase needs to be very specific for the automated tools to generate compliant code properly. As a matter of course, I never allow others to commit changes directly to the public SVN (otherwise anyone could commit anything, even break the entire repository).
The next update is very close (we’re talking Sunday at this point), and is the largest update since the release. Also, the delay in releasing the next update has enabled me to fix certain bugs nobody has noticed yet, but would have been a massive problem in the near future.
I am genuinely sorry for this delay. Flu is a pain, especially trying to get work done while suffering the painful throat, runny nose, and unending headache. This update on Sunday will make it well worth the wait. I’m then going to start taking a thourough look at the code you’ve sent me, and work it in to the system (remember, I have to plan changes outside the original design carefully to ensure they don’t break the wrapper generator or wrapper model itself).
My flu is abating quite a lot now (I still have a lot of pain when swallowing and my throat is very swollen still), so hopefully it’ll be completely gone come Sunday (as I’d very-much like to do another webinar to demonstrate the changes and all the new additions).
March 12, 2012 at 10:06 am
Hi
I got a problem :
I developp an application in a virtual machine (Oracle VirtualBox) with windows XP-SP3, Delphi XE, Delphi XE update 1
The application run fine under XP-SP3 but raise lot’s of Access Violation when I try to use it with Windows 7
Have you an idea ? Many thanks for a solution !
Best regards
March 12, 2012 at 10:38 am
Well, if it’s working fine on XP but not on Windows 7, that indicates your program is using something that’s available in XP but not Windows 7.
Are you making any calls to the WinAPI? Are you using third-party DLLs of any kind?
March 12, 2012 at 12:17 pm
I use WinAPI and VCL, the only dll is the lua5.1 one
My app was working fine untill this WE… I’m searching for the mistake and I don’t find what’s wrong
March 12, 2012 at 12:20 pm
I suggest trying again after the update I’m about to release in the next 10-20 minutes (will announce as soon as released)
March 12, 2012 at 12:32 pm
Think I fix the bug : I was using the Caption field of a window in a CompareText(…) without Synchronize() the call from a thread.
I’m using a AdvMemo (syntax coloring) from Tms Software and a LineHook in Lua for displaying the executed line… very fine
March 12, 2012 at 12:37 pm
No worries. Glad you got it sorted. Just be ready to make some changes to your code for this update!