supplierdeeply

Lua Scripting Integration

  • 46 Replies
  • 15836 Views
*

Offline Velo

  • *
  • 30
  • Publish
    Lua Scripting Integration
    « on: 27 / April / 2008, 05:43:03 »
    Advertisements
    Hi,

    I am in the process in finishing Lua integration in CHDK. See Lua Scripting

    Now I would like to contribute my work back to CHDK. CHDK more than doubled the usefulness of my camera. Thanks to all who made this possible!
    My plan is to to do the same to CHDK. This requires that my work will be accepted in the CHDK community. Is it the case?

    My personal opinion doesn't matter much, I think. But I find it VERY convenient to script in Lua than in uBASIC. Everyone will see/feel the difference once he tries Lua.   :)

    So, how should I proceed?

    What I don't want is another "Velo's Builds" entry in downloads. I think there are already far to many forks of CHDK.

    My current plan is to ditch uBASIC at the same time. Converting uBASIC scripts to Lua is not hard. Perhaps even a Lua Script converting uBASIC to Lua on the fly should be possible.

    Comments? Opinions?


    *

    Offline fudgey

    • *****
    • 1705
    • a570is
  • Publish
    Re: Lua Scripting Integration
    « Reply #1 on: 27 / April / 2008, 06:06:43 »
    Ditching ubasic may not be a very good idea, at least without a long transition period. Users have their own scripts and forcing them to port them to use a current build may not be desirable.

    Would it be hard to support for both lua and ubasic? Maybe require lua scripts to be easily identifiable by CHDK (like start with #!lua) and fall back to ubasic if it's not a lua script.

    *

    Offline Jucifer

    • *****
    • 251
    • [A710IS]
  • Publish
    Re: Lua Scripting Integration
    « Reply #2 on: 27 / April / 2008, 07:04:26 »
    Once you publish your lua-patch, I'll at least try it. (Probably I'll end up adding it to my build.) :]

  • Publish
    Re: Lua Scripting Integration
    « Reply #3 on: 27 / April / 2008, 07:08:12 »
    One comment, the UBASIC is a very simple scripting langage for non programmers also. LUA woud probably require a bit more programming experience.
    But we have to evaluate it  in practice, not by opinion!
    Great job Velo! I really would like to test it!


    *

    Offline fe50

    • ******
    • 3034
    • IXUS50 & 860, SX10 Star WARs-Star RAWs
      • fe50
  • Publish
    Re: Lua Scripting Integration
    « Reply #4 on: 27 / April / 2008, 08:28:04 »
    Sounds good to me, I'm looking forward to test LUA scripting !  8)
    My opinion: an optional second scripting language can enhance CHDK, anybody can decide to use uBasic or LUA. Perhaps it could cause some confusion with 2 languages...

    *

    Offline Velo

    • *
    • 30
  • Publish
    Re: Lua Scripting Integration
    « Reply #5 on: 27 / April / 2008, 16:15:54 »
    Here is the first version of the patch (its against trunk Rev 388)
    zSHARE - chdk-lua.patch.zip

    I bound all functions that where available in uBASIC to Lua, except md_detect_motion. It is implemented in some special way I didn't bother to analyse. But if someone beats me to it...

    I actually only tested shoot/sleep/get_prop/press/release/click because that are the only functions I need in my scripts. But the other ones are mostly very simple and should work out-of-the-box.
    I could use some help in testing all functions. For half of them I don't even know what they are supposted to do.

    Note that some function have now boolean parameters or results. This includes is_key,set_autostart,get_autostart,usb_power. Please inform me if some other functions should accept or return booleans instead of numbers.

    What is still missing are parameters. I concentrated on providing all functions first.
    I think I'll get to parameters in the next 2 or 3 days. Don't have much time weekdays.

    With the patch it should be possible to run both Lua und Basic scripts. If the script file ends with .lua or .LUA it will be run as Lua script.

    A new thing that some will experience is that you can now hang the camera with an improper script. Lua scripts are run until you interrupt them with shoot/sleep/press/release/click or wait_click. If you wait for an event make sure to sleep at least once in your loop.

    Errors will be shown in the script console window. Sometimes this window disappears very fast after the script stops. Don't know what to do about it.

    Have fun and report back how its working out!


  • Publish
    Re: Lua Scripting Integration
    « Reply #6 on: 27 / April / 2008, 19:55:25 »
    I only know a bit of the Lua language. But can you tell me if external module loading is possible or planned for this? I think that would be one of the most useful features over uBasic. Having a function library of timers, delays, AV settings tables etc on the card that can be reused in the main scripts.

    *

    Offline Velo

    • *
    • 30
  • Publish
    Re: Lua Scripting Integration
    « Reply #7 on: 28 / April / 2008, 02:38:20 »
    I haven't planed it in the first release. But it shouldn't be to hard to add this functionality.

    When Lua is accepted I plan more features like droping the 8 kb script limit or the just described module support.


  • Publish
    Re: Lua Scripting Integration
    « Reply #8 on: 28 / April / 2008, 04:00:12 »
    I haven't planed it in the first release. But it shouldn't be to hard to add this functionality.

    When Lua is accepted I plan more features like droping the 8 kb script limit or the just described module support.

    No it shouldn't be hard at all. As for Lua being accepted, I don't know why not. Most of the people new to CHDK are new to Basic as well. Lua is a very clean language and there shouldn't be any problems. Geez, it should even be simple to write a uBasic wrapper to Lua modules if the need be. I'm all for it. I tried a Pawn implementation but I'm not smart enough. But Lua is powerful and if this takes off it would be possible to try many things out that would otherwise have to be done by modifying the CHDK code itself. Congrats, Velo. Good job.

    *

    Offline Jucifer

    • *****
    • 251
    • [A710IS]
  • Publish
    Re: Lua Scripting Integration
    « Reply #9 on: 28 / April / 2008, 08:14:33 »
    tried the patch

    the good:
    didn't break ubasic

    the bad:
    couldn't get lua working :/


    the ugly:
    had to increase memisosize
    patching /makefile.inc (and /platform/makefile_sub.inc) causes an error in win when compiling:
    "../../../../tools/finsig.o: file not recognized: File format not recognized"


    trying to patiently wait for new patches :]
    « Last Edit: 28 / April / 2008, 14:28:44 by Jucifer »

     

    Related Topics