Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: LUA Libraries

Hybrid View

  1. #1
    Join Date
    Jan 2002
    Posts
    58

    Default LUA Libraries

    This will be my first contribution to the Girder community. If something like this has already been done, I'm sorry for covering old ground; I didn't find anything like it and I needed it.

    Ron, if this is useful maybe it should be posted in the download section? I plan on using it as the basis for some additonal libraries I'd like to contribute in the near future and it provides a simple way to handle large collections of code (similar to plugins). In addition, it removes the dependancy on Girder's builtin LUA editor (it's nice, but I've lost too much code to continue using it; I prefer an external editor like VIM).

    From the readme file:

    Load LUA Libraries

    The included GML file provides a small LUA script that will be executed
    on the GirderEnable event. The script provides 2 functions that can be used
    from any LUA script once loaded.

    loadLUALibraryDir(dir)
    This function is called with a single string argument that specifies a
    directory path (with no trailing "\"). The function looks for all files ending
    with the ".lua" extension in the directory and calls the builtin LUA function
    "dofile" for each one. This has the effect of loading a set of files which
    define useful functions to be used within Girder.

    loadLUALibraryDirs(...)
    This function takes one or more directory paths and calls the previous function
    for each path.

    The script also provides a global string variable, "lualib", which contains
    the path to the [proposed] default LUA library path (GIRDERDIR\lualib). When
    the script is executed (usually on a GirderEnable event), it calls the
    "loadLUALibrary" function with this path. This effectivly loads all the
    libraries found in the default LUA library path.

    To make effective use of this script:

    1) create a directory "lualib" in the main Girder directory (usually
    C:\Program Files\girder32)

    2) import the GML file into Girder and move the top level group "Load LUA
    Libraries" to the top of your GML so it will execute before any other
    script that may need the libraries that will be loaded

    3) place text files that define useful LUA functions in the directory created
    in step 1 (make sure the files have an extension of ".lua")


    Written by Thomas Bennedum (tab/frdfsnlght) for all Girder users.

  2. #2
    Join Date
    Jan 2000
    Location
    Jupiter, FL
    Posts
    11,349

    Default

    Great idea, there is one problem though, if someone does a 'reset variables' the scripting environment is reset completely, thus loosing all loaded libraries.
    Ron
    No support through PM

  3. #3
    Join Date
    Feb 2001
    Location
    Plano, TX, USA
    Posts
    3,055

    Default

    Maybe there could be one or more new events that would be generated when the script engine is initialized, terminated, reset or has another important state change? (like GirderOpen, ...Close, ...Enable, ...Disable, et al)
    Mark F

  4. #4
    Join Date
    Jan 2000
    Location
    Jupiter, FL
    Posts
    11,349

    Default

    Yes I was brainstorming about what message would be most appropriate. Another important question is how much can fit into two suitcases :-)
    Ron
    No support through PM

  5. #5
    Join Date
    Feb 2001
    Location
    Plano, TX, USA
    Posts
    3,055

    Default

    I was also thinking (not always a good thing). If you'd rather I could add an event to the WinLUAEx plugin that is generated when it sees the script engine reset notification. Then you could worry about a "real" solution when we move to G4.0.

    Your choice, as always.
    Mark F

  6. #6
    Join Date
    Jan 2000
    Location
    Jupiter, FL
    Posts
    11,349

    Default

    Hmmm,.. I think it would be better to implement this now and make Girder 4 use the same method as Girder 3.2. ( I'm releasing an update tonight or tomorrow anyway ).

    How about:

    ScriptReset

    that is triggered *only* when the, surprise, scripting engine is reset. Do you see any objections to this ?
    Ron
    No support through PM

  7. #7
    Join Date
    Jan 2000
    Location
    Jupiter, FL
    Posts
    11,349

    Default

    Download Girder 3.2.7a it has the new "AfterScriptReset" event.
    Ron
    No support through PM

  8. #8
    Join Date
    Oct 2001
    Location
    Bulgaria
    Posts
    270

    Default

    Ron, using the reset function in the script editor doesn't call AfterScriptReset event. Is this the way it should be?
    Also don't you think that this event should be called when Girder opens?
    I know there is an event OnGirderOpen but when girder opens it also resets the Script so I think the AfterScriptReset event should also be called.

  9. #9
    Join Date
    Jan 2000
    Location
    Jupiter, FL
    Posts
    11,349

    Default

    1. It should have done that too yes.

    2. No. The event is only triggered when the engine resets. Just assign two events to it.
    Ron
    No support through PM

  10. #10
    Join Date
    Jan 2000
    Location
    Jupiter, FL
    Posts
    11,349

    Default

    I've updated Girder to 3.2.7b, it has the fix.
    Ron
    No support through PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •