Slashdot Mirror


Extending Games With Lua

RealDSmooth writes "2old2play.com has a nice article up about extending World of Warcraft, Neverwinter Nights, and other games using Lua, a light-weight programming language made specifically for enhancing and extending games. It goes into some great details about what's available today, and where Lua is heading in the future."

18 of 55 comments (clear)

  1. Honestly... by VoidWraith · · Score: 3, Funny

    I think they need to take Bob's advice. Very irritating to read.

  2. Umm, no, not specifically for extending games by cookd · · Score: 5, Informative

    Lua was definitely not designed specifically for extending games. It is a general purpose scripting language designed to be easy to embed and easy to use. It has been embedded into a number of games because it is hightly suited for this kind of embedding, but it was not originally intended for games.

    I've been working with Lua off and on for a while. I have to say that it is pretty darn cool. It is really easy to embed, really easy to extend, and really lightweight (about 90k or so). The language is very simple, but still supports a lot of advanced programming concepts like closures.

    --
    Time flies like an arrow. Fruit flies like a banana.
  3. Off-Topic: Apostrophe Abuse by venomkid · · Score: 2, Funny

    ...for making game's cooler...
    ...past the shipping titles intentions...
    ...if you're games have Lua capabilities...
    ...and add-on's that you can download for free...

    ...and that's just the first two paragraphs...

    ...who's editing that site?

    --
    vk.
    1. Re:Off-Topic: Apostrophe Abuse by Rallion · · Score: 4, Funny

      ...who's editing that site?

      For the love of the sweet sweet Jebus, I hope nobody is.

  4. Um, yeah. Not so much. by Sliptwixt · · Score: 2, Funny

    It's like bastard child of a VB nun mistakenly locked in a room full of Perl madmen.

    Turned me off from doing any scripting for WoW completely.

  5. Not really well researched article by Anonymous Coward · · Score: 4, Informative

    Neverwinter Nights does not use LUA, it uses our own scripting language, NWScript which has been developed from ground up in house and has nothing to do with LUA.

    LUA was used for scripting in Baldur's Gate series however.

    BioGeorg

  6. Pretty lousy article... by MrDomino · · Score: 3, Informative

    Aside from the fact that it appears to have been written by somebody whose teachers apparently overlooked the usage of the apostrophe when teaching him English, the article didn't really say all that much. Reading the summary, I was expecting some details about Lua itself, or maybe even some information about where it is headed in the future. All the article pointed out was that Lua was being used in some games. ...... Real informative.

    But seriously, Lua's a great language. Full lexical scoping and first-class functions alone give it insane flexibility and power, and its table data structure is implemented very well. In general, Lua is one of the most well-thought-out languages I've ever seen; its creators have taken great pains to get all of its functionality into it while still maintaining a low profile (the stand-alone interpreter takes ~150KB of space) without resorting to kludges or hacks, and these efforts have paid off. I wouldn't think of using anything else to extend a program.

  7. Re:Dawn of War by JVert · · Score: 2, Funny

    Pure genious, the download page has background music. The only page that has links to pop up videos... with sound... so you can hear the background music, and the video.. at the same time. Too smart for this world is what that is. Oh and the video just ended with the progress bar at %30. Is this game really playable? Looks nice, but what i've seen so far the only war is in the web development team.

  8. MISLEADING ARTICLE!!! by RootsLINUX · · Score: 2, Interesting

    "Lua, a light-weight programming language made specifically for enhancing and extending games"

    Wrong bitch!
    Lua is *not* a language that was specifically made for enhancing games. True, it has a great use in enhancement and extension of games (in fact I use it in my game), but it is used in MANY pieces of software outside gaming. Here is proof.

    For the bastards who are too lazy to click the link, here's a sample of the projects that use Lua (outside of gaming)
    - Automatic configuration of network devices
    - Heart Institute Monitoring Network
    - CPC4400 Embedded Switching Platform
    - Horus Alarm monitoring software

    Unreal script is an example of a language designed specifically for games (or just a game in this case). Lua is not one of them. I would like to encourage the editors to check their submissions over thoroughly and stop mis-educating the Slashdot crowd. Of course, that's probably as likely to happen as Apple is to announce that they're switching back to PowerPC. We can hope, but it probably won't do no good. :(

    --
    Hero of Allacrost, a FOSS RPG for *NIX/*BSD/OS X/Win
  9. Game Development with Lua, other projects by Noksagt · · Score: 3, Informative

    My officemate literally just purchased Game Development with Lua. It is a neat book.

    However, Lua is used for other things, includinge the ion window manager, the SciTE editor, the Elinks text webbrowser and more.

  10. Lua is simple, functional, and ideal for games by Deraj+DeZine · · Score: 3, Informative

    I embedded Lua into an as-yet-unreleased top-scrolling space shooting game (a la Raptor) and it is a very handy language for embedding. I believe it was originally designed as a language simply for configuration files, but is has grown into a capable (but very simple) language.

    The entire manual that explain the whole language as well as the C embedding interface and the optional standard libraries is probably less than 100 pages printed. The source code is around 10,000 lines of C code, I believe.

    Performance was also particularly impressive provided you know what you're doing. If you're new to functional programming, you might want to read up a bit. Also, it is a good idea to have experience with recursion and other such elementary topics.

    Overall, I couldn't believe how easy it was to build Lua into my little project and I doubt I'll ever take a look at another scripting language because Lua is just that good.

    The scheme I chose to use for my project is that it reads in all the Lua files in a directory and using the game engine's simple API (in Lua), different scripts add things like ships or new weapons. This allows the player to write a quick script for a new weapon (e.g. a rail gun), drop the script in a directory, start the game, and then use that weapon. There's basically no overhead. I think that's pretty cool and encourages people who don't know how to make an entire game to still have a fun time extending the game by themselves.

    --
    True story.
  11. Ooops..Linky by Noksagt · · Score: 2, Informative
  12. mangband/tomenet by GoNINzo · · Score: 2, Informative

    I have to say that it really has helped the lives of mangband and tomenet. You don't need to be a fancy c programmer to add abilities to the games, plus you can make some of the changes live, which is really nice. Kind of neat, I just wish that some of the debugging tools were a little cleaner to work with.

    --
    Gonzo Granzeau
    "Nothing the god of biomechanics wouldn't let you into heaven for.." -Roy Batty
  13. Re:Python? by snuf23 · · Score: 2, Informative

    Civilization 4 will use Python and XML for customization. The system is supposed to be extremely flexible and be good for total conversions.
    Could make for some neat mods. I'm hoping we'll see some kind of Master of Magic game come out of it.

    --
    Sometimes my arms bend back.
  14. Re:Python? by Pxtl · · Score: 3, Informative

    The problem is that Python (in it's base form) is wholly inappropriate for this. Python has no restricted execution, no sandbox, and many of the core Python commands can damage the system. File access is within the builtins.

    It takes a lot of work to rip out all that dangerous stuff and convert Python into a vessel appropriate for running untrusted code. Because any game with a scripting engine will be modded, untrusted code is a given.

  15. I Love Lua by Nurgled · · Score: 3, Informative

    I've embedded Lua into all sorts of things. Never really finished any of it, but I did embed Lua into the BUILD engine to replace the game code written in C. I've also been working on embedding it into Quake 3 Arena to do similarly, though unfortunately real life is getting in the way of doing much there. Lua is great because you can make what you want with it. It has no builtin functions, so it's completely up to the embedder what gets included. The bundled coroutine library is very useful in games, too. It doesn't even have an object model of its own, meaning that you are free to invent one based on the simple structures it provides.

    The adventure game Grim Fandango was based on Lua, as was the latest Monkey Island game. Lua gets everywhere. It's in text editors, web servers, games, your shell... you name it. It's probably somewhere on your computer right now, hidden inside some application.

  16. Lua's sandboxing by Morgaine · · Score: 2, Informative

    I read one of the links above, comparing Python and Lua, but it doesn't talk about sandboxes. Does Lua have one or does it just do multiple interpreters?

    Both of those apply. As Lua is fully reentrant and tiny, you can have any number of Lua VMs active concurrently in a program, and they're all naturally disjoint from each other.

    In addition, Lua execution is inherently sandboxed with respect to the operating system because the base interpreter provides no system functions at all, and so it can affect only its own internal state. You need Lua's standard libraries before you can do file operations etc with it, but those libraries are available only if the designer chose to link them in to your executable, so the sandboxing is unbreakable "by default", bugs excepted.

    Diametrically opposed to the above, many other Lua executables exist which contain dynamic loaders to allow the interpreter to be extended on the fly with arbitrary code, ie. to provide high functionality rather than sandboxing.

    Lua can be pretty much anything you want it to be. The base VM just gives you efficient and flexible scripting, and imposes no usage policy at all.

    Re your point about Tcl, that language suffers from its string orientation when applied to gaming, although it's fine for embedding as a simple configuration language. Lua is stunningly fast, so its use in games goes far beyond mere configuration and UI scripting, right into the hearts of engines.

    --
    "The question of whether machines can think is no more interesting than [] whether submarines can swim" - Dijkstra
  17. How About Scheme? by RAMMS+EIN · · Score: 2, Insightful

    While I completely agree with your post, the last sentence bites me:

    ``I wouldn't think of using anything else to extend a program.''

    I'd just like to propose Scheme as an alternative to consider. Scheme has all the characteristics you applaud: great design, immense flexibility, and low footprint. Comparing Scheme to Lua:

      - Scheme is a Lisp dialect, and, as such, uses s-expressions (basically lists, think lots of parentheses). Some people find this annoying, but it makes the syntax very regular and easy to parse.

      - Scheme has a reader that reads s-expressions and a writer that writes them. This is convenient for reading and writing data, but (since Scheme programs are built of s-expressions) also allows easy processing of program code.

      - Scheme offers macros which can be used to extend the syntax of the language. Few other languages offer these; it seems to go together with the parentheses (things like C macros are nowhere near as great)

      - Scheme is standardized, and there are many implementations; anything from simple interpreters to complete IDEs and high-performance compilers

      - Scheme is old, and therefore less prone to the incompatible changes that seem to plague more modern languages

      - Scheme has first-class continuations, which I believe Lua doesn't have. In a nutshell, first-class continuations allow you to break the call-return control flow; you can return as many times as you like, or not at all. This is a very flexible feature, which can be used to implement certain things very concisely and elegantly.

      - Standard Scheme does not contain structures or objects as found in other languages. Many Scheme implementations support these, or allow one to implement support using macros, but programs that use these features won't be completely compatible with all Scheme implementations.

      - Scheme is used extensively in programming language and compiler research. It's also used to teach programming in a number of universities. Scheme is covered in various books, many of which can be read online.

    I think that about sums it up. Note that I'm not saying anything is wrong with Lua, I'm just pointing out that Scheme is worth looking into, as well.

    For more information, schemers.org is a good place to start.

    --
    Please correct me if I got my facts wrong.