We have detected that cookies are not enabled on your browser. Please enable cookies to ensure the proper experience.
Results 1 to 11 of 11
  1. #1

    Questions: Plugin Testing, OO LUA

    Hello Lua Devs,

    I'm new to LUA scripting but have been a professional programmer for a long time. As such, I have a few questions regarding LUA scripting.

    I was wondering how you write/test/debug your plugins

    Do you just add debugging code, fire up lotro with your plugin enabled and go from there?

    Do LUA debuggers (such as the debuggers list here) work for debugging lotro lua plugins?
    I know any IDE/text editor would be adequate, but is there an IDE that most LUA devs prefer?

    In regards to "OO LUA"

    I read from Writing LoTRO Lua Plugins for Noobs:
    Lua is not really an object oriented language, but by creating a 'Class' object, Turbine has created a wrapper that makes Lua feel a little more object oriented. The class.lua file can be found in the Turbine samples but you should not depend on end users having the Turbine samples installed so it is usually best to include a copy in your own project folder and reference it from there.
    That was written in Oct of 2011. Does it still hold true that if I wanted to use class.lua that I'll need to include a copy of the Turbine samples?

    Is there any noticeable overhead of using Turbine's class.lua?

    Thanks in advance!

  2. #2
    Join Date
    Sep 2010
    Mountains of Southern CO
    I don't know if this helps but you may want to look here


  3. #3
    I use Notepad++ for its keyword highlighting and section collapsing, and because it handles UTF-8 encoding particularly well.

    You can use other class implementations besides Turbine's. (In fact, if you choose to use Turbine's, you will probably want to just copy it directly into your project.) There are other approaches that are variously more robust or better performing, depending on whether they create shallow copies of tables and metatables or use references. Depending on the complexity of your plugin, you may not feel the need to create classes (or derive from Turbine's) at all.

    You can't attach a debugger to the in-game Lua environment (that I'm aware of), but you can use the script log or chat output and conditional commands to keep track of what your plugin is doing.

    The current API documentation is slightly out-of-date, but most of the changes can be easily discerned simply by looking through the global tables in _G. If you have any questions, authors here or on lotrointerface.com will be happy to help you.

  4. #4
    Join Date
    Jun 2011
    I use Notepad++ to edit and I debug out of of console messages (heh ...) and a a small plugin I wrote to inspect the environment/tables. Effective enough for the purpose of writing game plugins.
    [size=1]Freeps (Snowbourn): [b]Equanor (R11 MNS)[/b] - Equendil - Orlo - Equadoc - Quaolin - Oshia - Kaolin - Equaric - Equorn
    Creeps (Snowbourn): Veloch (R9 RVR) - Velrow (R10 BA) - Velkro - Oruk - Velrot - Velreth
    Author of the [url=http://tiny.cc/2zm50w]Legendary Item Planner[/url], [url=http://tiny.cc/m1m50w]Bootstrap[/url] and [url=http://tiny.cc/41m50w]Baruk[/url] plugins.[/size]

  5. #5
    Join Date
    Jun 2009
    I use SciTE (http://www.scintilla.org/SciTE.html) for coding which has support for Lua.

    In terms of debugging, you can use the Turbine.Shell.WriteLine("some string") function to see what's going on in your code as mentioned in a previous post. Or if you're really lazy like me and can't be bothered to even write that every time you can make a Debug() function.. here's the one I use:

    function Debug(STRING)
        if STRING == nil or STRING == "" then return end;
        Turbine.Shell.WriteLine("<rgb=#FF5555>" .. STRING .. "</rgb>");
    This means when I'm testing and want to see the value of something I can just use Debug(ValueToBeTested).
    The RGB tags cause the message to appear in a different colour (some reddish colour) so it's easier to see.

    It's also really handy when using lua tables to have a dump() function which will output the entire table.

    Again here is the one I use:

    function dump(o)
        if type(o) == 'table' then
            local s = '{\n'
            for k,v in pairs(o) do
                    if type(k) ~= 'number' then k = '"'..k..'"' end
                    s = s .. '['..k..'] = ' .. dump(v) .. '\n'
            return s .. '}\n'
            return tostring(o)
    I didn't write this, but found it when searching the internet and it's been one of the most useful functions of all (I don't recall where so apologies for not citing).

    So when I'm creating a table to store a load of data, I can just Debug(dump(MYTABLE)). Really easy.

    Edit: Oh and Equendil's 'Here Be Dragons' is also an essential aid as the official lua api documentation isn't very up-to-date.
    Galuhad | Narvelan
    Lore Breakers of Evernight (formally of Eldar) | Plugins

  6. #6
    Hmm... I use four or so methods:

    1. LUA error messages - use them to track down a line in the code, and mentally backtrack to figure out where the error occurred.

    2. Symptoms - given a particular anomalous/erroneous behavior, figure out where it differs from the expected behavior, identify where in the code the likely error is, mentally simulate the code and track down the error.

    3. Eval, for when I want to look into the state of a currently running script, or if I want to do rapid prototyping.

    4. If all else fails, debug via WriteLine.

  7. #7
    Join Date
    Mar 2007
    I typically write in plain old Notepad and debug with a combination of Turbine.Shell.WriteLine statements and the debug.lua file which is included with most of my plugins. Debug.lua allows interactive execution of lua statements as well as setting values to watch and has a tree view of the environment.

  8. #8
    Join Date
    Sep 2010
    Mountains of Southern CO
    I think Fredelas suggestion is good I use Notepad ++ when I work on PHP for websites, very handy tool for script easy to use and many features. And it's free!

  9. #9


    Thank you for all the replies, suggestions and advice - I really appreciate it!

  10. #10
    Join Date
    May 2010
    Idaho, USA
    I was using Eclipse IDE with the LuaEclipse plugin. The "beta" plugin worked best, but I had a pain getting it installed since the update site was having problems. Once I got it all installed I left it alone. It really helped me because it caught scripting errors as I typed them.


  11. #11
    Join Date
    Feb 2007
    Toronto, Ontario, Canada
    There is some unit testing available for LUA, I know I have tried using it a little bit with LOTRO plugins.

    Turbine actually included some testing code in their own download file. I just don't remember how to use it at the moment.



Posting Permissions

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

This form's session has expired. You need to reload the page.