Reinvent The Wheel

Round is nice, but we can do better!

Lua4Delphi

Lua4Delphi Released!

| 64 Comments

UPDATE 1 (6th Feb 2012)

  1. All known bugs have been fixed
  2. Packages have been added (to both LKSL and Lua4Delphi) for Delphi 2010 and XE
  3. 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 UTC session ended
  • Sunday Feb 12th 12:00 UTC cancelled due to completing next update. Please attend the 21:00 UTC session :)
  • Sunday Feb 12th 21:00 UTC session ended
  • Sunday Feb 19th, 00:00 UTC
  • Sunday Feb 19th, 12:00 UTC
  • Sunday 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!

Author: Simon J Stuart

Automation and Productivity Systems Specialist, Author of various Components, Libraries and Tools for Embarcadero Delphi, Embarcadero Technology Partner, Founder and CEO of LaKraven Studios Ltd, Father of 2 (+ 2 dogs), Credited Technical Editor, Published Technical Author, Seeker of peace!

64 Comments

  1. 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 :-)

  2. Congratulations Mate. I bet it feels good to finally get this thing out the door.

  3. 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 ?

  4. I cannot access svn ? server is down ?

  5. 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).

    • 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 ;)

  6. 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) ?

  7. 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

  8. Pingback: [LUA] Datei mit Handle auslesen - Delphi-PRAXiS

  9. 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 ?

    • 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)!

      • 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…

  10. 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;

    • 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?

  11. Congrats!, I’ll give it a try!

  12. Seems to have a bug with <>
    A defined method raise an exception while similar code with <> run fine

  13. Seems to have a bug with ‘Managed “Unbound” approach’
    A defined method raise an exception while similar code with ‘Managed “ObjectMethod” approach’ run fine

  14. 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)

    • 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 :)

  15. 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?

  16. Waiting for next webinar … I wish you a speedy recovery ;-)

  17. 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….

    • 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).

  18. 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

    • 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?

      • 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

        • I suggest trying again after the update I’m about to release in the next 10-20 minutes (will announce as soon as released)

          • 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

          • No worries. Glad you got it sorted. Just be ready to make some changes to your code for this update!

Leave a Reply

Required fields are marked *.

*


*