Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
PC Games (Games) Programming IT Technology

Extending Games With Lua 55

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."
This discussion has been archived. No new comments can be posted.

Extending Games With Lua

Comments Filter:
  • Honestly... (Score:4, Funny)

    by VoidWraith ( 797276 ) <void_wraith&hotmail,com> on Thursday September 15, 2005 @07:26PM (#13571530)
    I think they need to take Bob's [angryflower.com] advice. Very irritating to read.
    • Holy crap. The grammar problems of this article run far beyond apostrophe misuse. Besides the terribly awkward phrasing and missing commas, overuse of parentheses, and common their/there/they're your/you're crap, here are some of the stranger mistakes:

      javascript
      web-pages
      (excusable if the author is German, but I doubt it)
      Baldures Gate
      Neverwinter nights
      RPG game
      develope
      user-interaction
      to add flare, and fun
      (two mistakes within three words!)

      The sad thing is that the article is nearly devoid of conten

  • by cookd ( 72933 ) <.moc.onuj. .ta. .koocsalguod.> on Thursday September 15, 2005 @07:28PM (#13571535) Journal
    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.
  • by venomkid ( 624425 ) on Thursday September 15, 2005 @07:29PM (#13571539)
    ...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?
  • Dawn of War [dawnofwargame.com], an RTS game without resource harvesting as you know it, uses Lua too.
    • by JVert ( 578547 )
      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.
      • Actually yes, the game itself is darn good. The developers are really into the Warhammer 40,000 universe and it shows. It's more of a squad-based action game than an RTS; it is an RTS but it's got a different take on resources and bases. It feels much more like a tactical game where you build your base than an RTS,

        Google up the demo.

        Oh, and I didn't get any sound. No video either. Hmmm. But I'll give 'em credit for size of the screenshots, I hate checking out a game's site and getting small images.
      • It's playable but patching your newly bought (t costs a tenner now) version to the latest requires that you apply every single patch in order.

        Oh and don't be fooled by the labelling, "Normal" difficulty means "Damn Easy".
    • Dawn of War is a VERY good game. I'm not heavily into RTSes as a general rule, but I played that one a lot. Great units, very atmospheric, lots of strategic depth. Designing an RTS from battle-tested(heh) pen and paper rules was a fantastic idea. It's been tried before, but this one really got it right.

      Major downside is that the single player game is exceedingly short. They're just about to ship an expansion, Winter Assault, on the 20th. It'll add a bunch of single-player content, as well as another p
  • 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.
    • by Anonymous Coward
      Well, the lua 'or' and 'and' shortcut logic operators are sort of cool because you get shorthands for using defaults for variables,
      so instead of
        PHP: doSomething(isset($a)?$a:-1);
      you can do:
        Lua-like: doSomething(a or -1)

      This removes the redundancy in the php statement.

      I felt the embedding of lua might be kind of hard, it looked like programming postscript to me
    • How do you figure? I've actually been extremely pleased with Lua, and I avoid VB and Perl whenever humanly possible. "if...then...end" statements don't really make it VB-like, thank goodness. It isn't a langauge for applications by any means, but for writing one-off scripts, it's remarkably well-suited to the job.
  • by Anonymous Coward on Thursday September 15, 2005 @07:47PM (#13571680)
    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
  • by MrDomino ( 799876 ) <.mrdomino. .at. .gmail.com.> on Thursday September 15, 2005 @07:47PM (#13571681) Homepage

    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.

    • How About Scheme? (Score:3, Insightful)

      by RAMMS+EIN ( 578166 )
      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 eas
  • I'm no hardcore programmer but this kind of thing seems tailor-made for using Python. Do any games use python for this kind of stuff?

    Can some more knowledgable people post some pros/cons of using python for this, like issues with the byte-compiling?

    • There are numerous comparisons. . Lua is nice because it is tiny. Python is nice because it is versatile.
      • Ooops..Linky (Score:3, Informative)

        by Noksagt ( 69097 )
        Link [lua-users.org]
        • Not bad, but it's bound to be Lua-biased because of the source.

          I'm working on an open-source game with a few other people, and we're using Python as the main language, with bottlenecks to be rewritten in C/C++ as necessary. A powerful Python scripting interface will be very simple to implement.

    • Re:Python? (Score:3, Informative)

      by snuf23 ( 182335 )
      Civilization 4 will use Python and XML [civfanatics.com] 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.
    • Re:Python? (Score:4, Informative)

      by Pxtl ( 151020 ) on Thursday September 15, 2005 @11:34PM (#13572969) Homepage
      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.
      • 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?

        I have to say that Tcl is pretty good for this kind of thing too, although it is certainly bigger than Lua. It has sandboxes and multiple interpreters that you can control from both C and Tcl itself. You can also do threads, if you want. And the language is also pretty easy to learn for newcomers, like most scripting languages - especially considering t
        • Lua's sandboxing (Score:3, Informative)

          by Morgaine ( 4316 )
          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
          • Sounds like the Lua approach is pretty smart for what it's meant for. Build it small and make it extensible is often a pretty good way of doing things. One thing that's missing from Tcl in terms of sandboxing that your comments don't exactly cover WRT Lua is the ability to really limit things. For instance, Tcl's sandbox won't stop a "while { 1 }" type of situation - you'd have to have a control thread or some other means of defeating it (it's certainly possible, just not as easy as it could be).

            You do m
        • I'm not sure what you mean by interpreters - are you talking about states?

          Python, when embedded, runs in a single global state, IIRC. With Lua, you can create any number of separate Lua states which are effectively their own sandboxes, and then run scripts in them as you choose.
      • Actually Python supports restricted execution. This browser Grail [sourceforge.net] is writen in Python and supports Python applets that run securely with rexec. As for the Python used in games matter I suggest my article about it [sylphis3d.com]. The use of Python in games is discussed along with some things that are only possible with Python.
        • I realise that this reply is very late, but Guido has long since deprecated rexec, and apparently it was never really safe. Currently (and for many years) the mainstream Python release has no working method for running untrusted code.

          While many platforms include their own solution (Zope, for example) no-one seems to have released an officially dedicated distribution for restricted code. To my knowledge, Stackless has the same weakness.
    • Eve-Online is heavily based on python for server and client. Battlefield 2 has all its game scripts written in python too. I know there are many others, but those are the 2 I'm mainly aware of.
    • Lua was designed from the start to be embedded in other programs (although not specifically games, as the article says). It is tiny (less than 100kb), and written in strict ANSI C (so it is *very* portable and can run on any game console). It is also very easy to extend both with the host language (be it C, C++ or Java) and Lua itself. Recently, it has gained a very nice JIT compiler (still in alpha) for the x86, with other platforms to come.

      Python, although nice, was not designed for this kind of use.
    • It depends a lot on the platform. I could conceivably see Python used in PC and possibly next-generation games, but for current generation consoles, it's too large. It's very difficult to get the code alone under 1MB, whereas the Lua code can fit within 100KB.
    • Python's really clunky compared to Lua. It -can- be embedded, but it's more trouble than it's worth, IMHO. For what Lua does, it's the better langauge, I think. It's more designed for security, too - when you embed Lua, you choose which of the standard libraries to load, including string handling, table handling, and IO. For something like WoW, you just turn off (don't load) the dangerous libraries and disable the ability to load them from Lua, and bam, you have a reasonably safe script execution environmen
    • The reason why at least one game shop uses Lua rather than Python is that Lua was written by just a few people. They are both under similar "free, non-copyleft" licenses, but in the case of Python, what makes the lawyers nervous is that the Python code has (and has had) many contributors, any of whom may step forward and demand their pound of flesh at some future time. The point is not that the case would be successful, but companies want to avoid going to court and exposing their inner workings. This won
  • by RootsLINUX ( 854452 ) <rootslinux@gmail.cDEBIANom minus distro> on Thursday September 15, 2005 @07:56PM (#13571735) Homepage
    "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 [allacrost.org]), but it is used in MANY pieces of software outside gaming. Here is proof. [lua.org]

    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. :(
  • by Noksagt ( 69097 ) on Thursday September 15, 2005 @08:01PM (#13571766) Homepage
    My officemate literally just purchased Game Development with Lua [amazon.com]. It is a neat book.

    However, Lua is used for other things [lua.org], includinge the ion [cs.tut.fi] window manager, the SciTE [scintilla.org] editor, the Elinks [elinks.or.cz] text webbrowser and more.
  • by Deraj DeZine ( 726641 ) on Thursday September 15, 2005 @08:12PM (#13571841)
    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.
  • mangband/tomenet (Score:3, Informative)

    by GoNINzo ( 32266 ) <GoNINzo.yahoo@com> on Thursday September 15, 2005 @08:42PM (#13572026) Journal
    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.
  • As GoNINzo pointed out, it's nice to be able to make changes at runtime while creating a game. Being able to tweak behaviors without having to save_gamestate-> exit-> recompile-> restart-> reload_gamestate is a huge time-saver when you're fine-tuning. And anything that allows you to experiment easily will increase your ability to be creative. After all, many advancements come about accidentally through tinkering

    Of course, it also coddles a bit of laziness on the design side, so if you're not c
  • Has anyone touched the Game Monkey [somedude.net] yet?

    Seemed nice.
  • I spent a couple months scripting scenes for the Hero6 project. I don't know if the project is still active anymore, but the building of the game was heavily centered on LUA scripts that made event calls to the game engine, which I think was written in either C or C++. It was an excellent approach, and LUA was perfect for the job; it made development very simple and easy.

  • I Love Lua (Score:4, Informative)

    by Nurgled ( 63197 ) on Friday September 16, 2005 @03:20AM (#13574011)

    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.

  • Except, of course, for the fact that Neverwinter Nights doesn't use Lua at all. It's using a custom C-like language.

    Lua's cool and all (and BioWare has used it for the Baldur's Gate games and the underrated MDK2), but it's not in NWN or NWN2.

    In other game scripting news, Freedom Force and its sequal use the delicious Python [python.org].
  • I don't know Lua, except for its name. But I do know UnrealScript very well (the scripting language of the UnrealEngine), a language that was written with games in mind.

    Lua is just an interpreted programming language right? So you still need to create bindings from the game to the Lua environment. How difficult is that to do? How does Lua compare to using Python (for example) as script language? What makes Lua so great? Nothing about that in TFA, just some examples where it's used.
  • What a pointless article. I can summarise it (removing all the grammatical mistakes, and incorrect facts):

    "Some games can be extended with Lua."

    Wow! Cos, like, I'd never noticed any of my WoW addons using Lua, and never opened any of the files in curiosity. No...

    Anyway. Anyone who actually uses Lua out there? What's a good site with a tutorial on how to develop an addon, or just an intro to the language? Sure, I can google, but with an article like this I'd expect a little more info for the 'hardco

A morsel of genuine history is a thing so rare as to be always valuable. -- Thomas Jefferson

Working...