User Tools

Site Tools



So easy a Dromeder can do it

LgScript is a custom script module for Thief, Thief 2, and System Shock 2. With it you can create your own scripts using the Lua language.


A simple script might looks like this.

function SlashStimStimulus(message)
    local link = lgs.LinkSrv.GetOne("ControlDevice", script.objid)
    local dest = lgs.LinkToolsSrv.LinkGet(link)
    lgs.DamageSrv.Damage(dest, 0, message.intensity / 2, message.stimulus)
    return true

In plain English, this means:

  1. Listen for the message SlashStimStimulus. An object gets this message when a receptron action is Send to Scripts.
  2. Get the destination of a ControlDevice link.
  3. Damage the linked object with half the strength of the stimulus.

Recent News

2011-05-15 Is this still here? Guess it would help if I released it at some point. Oh, but I’ve ripped out most of my Lua modifications. No more case-insensitivity.

2009-09-16 The second test release has been uploaded. Use of the linkset iterator (from LinkSrv.GetAll) has been simplified. It is no longer necessary to call pairs, just use the value directly with the for-in loop. You also shouldn’t have to worry about calling Release, and the Data method can return a table.


Download the latest build:

The LgScript source code is hosted on GitHub.

The first thing you want to do when you unpack the archive is to run the QuickTour.bat file. This will introduce you to the Lua language. The interactive interpreter lgscript.exe can be used to test your scripts. However, the services available when using scripts in-game aren’t in the interactive interpreter. NOTEME Eventually there will be an emulated environment for simulating a script running in the game.

The other files in the archive are lgs.osm which is the script module that you copy to the game directory. In the scripts folder are examples of scripts. LuaDoor.lua is a complete example implementing the StdDoor script. In your fan-missions, you will include the OSM and any necessary scripts. The dh2.osl module is also provided if you want to use the DarkHook service.

How to Use

FIXME Please read and critique all of these tutorials.

The language reference describes Lua as implemented by LgScript. Read it if you have never used a programming language before, or are unfamiliar with Lua.

To begin writing scripts for games, read Getting Started, then the script examples:

Useful references when writing scripts:


  • bugs — Add information about problems or feature requests to this page.
  • Questions — Ask questions. Maybe even answer some if you can.
  • Useful Tips — Share helpful tips and sample scripts for others to learn from.
lgscript/index.txt · Last modified: 2013/01/23 08:32 (external edit)