[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: A game console
- From: "Trevor Powell" <lua@...>
- Date: Sun, 5 Dec 2004 20:54:35 +1100 (EST)
>> Has anyone developed a "Lua Console" for the PC version of a game, such
>> that designers could author tests by writing Lua into a little text
>> editor, and get instant feedback from gameplay in an attached window?
>
> Not that I am aware, but there is a lot in game studios that is
> developed but never released outside...
I've recently written a Lua interface into the game systems we use on our
PS2 titles. Thus far Lua hasn't actually be used or shipped in any of our
finished titles, but it's there in our current development projects,
running a debugging console and providing scripted access to various
in-game functions.
The console works as one would expect. One plugs a USB keyboard into the
PS2, and then (in Quake fashion) hits the tilde button to drop down the
console pane. The user then has a fully functional Lua interpreter, with
a number of game functions bound into it.
I divided up the functions into 'libraries' (actually, tables). The key
ones would be:
lua.load("filename") - loads the named script
lua.register("filename") - loads the named script, and registers it with
the list of loaded scripts. This is useful for calling:
lua.reload() - reloads all registered scripts.
Other fun ones:
hud.setMessage("Text") - makes a message visible on the screen
player.getPosition() - returns the current player position
player.setHealth( 90 ) - sets the player's health level
effects.spawn("sparks", player.getPosition()) - spawns a specified graphic
effect at a specified position
...and so on and so forth. With these sorts of bindings, I've written
several minigames, mostly to amuse myself, but also to demonstrate the
power of scripting to some of my colleagues. So we have a two-player game
of Pong, a multiplayer 'golf' game (played using in-game characters and
physics systems), a blatant rip-off of Flood (if anyone remembers that old
game), a racing-style 'time trial' game mode, and several other little
mini-games, all scripted and entirely outside of the main game executable.
That said, we don't have any commands at all for creating levels (or any
other kind of geometry) via Lua. There are two reasons for this. The
first reason is that creating and managing geometry for large levels
requires a lot of memory, and will cause significant memory fragmentation
when running in small memory footprints like on the PS2, if it's feasible
at all. The second (and more practical) reason is that large-scale
geometry production tends to be significantly easier to manage in a
package that was designed for that. We used to use SoftImage, and have
now moved to XSI. Others use 3DStudio Max or Maya. Groups with smaller
budgets often use Blender, or other low-price (or free) software.
While authoring geometry in a text-based format might appeal to hard-core
programmers, the fact of the matter is that even the developers of POV-Ray
don't create their 3D scenes that way any more (at least, according to the
interviews I've read). It's simply faster and easier to create and edit
3D geometry in a graphical package which lets you work interactively, than
it is to describe all the details of your level in a text format.
Trevor Powell