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 end
In plain English, this means:
Send to Scripts.
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: lgscript-test2.zip.
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.
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: