Skip to reading
Lua Scripting

How to read the code

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page
On this page

USING THIS GUIDE

Each lesson explains a piece of Lua or an editor control. Start with the subject you need for your game.

Complete records and fragments#

A complete Lua record starts with local Script = {} and ends with return Script. You can read it from top to bottom. A fragment shows only the lines needed to explain a point. Its caption tells you where those lines belong.

Names that belong to your game#

A word in quotes such as "archive_panel" can be an editor record ID. If you use the code with an existing GUI, substitute its ID and the ID of its text box. Built-in helper names such as GetGUIElementProperty stay exactly as written.

Three ways a script gives you an answer#

Source table from How to read the code, page 18
Log(message)Writes a line of output you can read while developing.
ShowMessage(...)Displays a message to the player.
return valueHands a value back to the function that called the script.

Where to look things up#

The event-handler table starts on programming page 26, helper functions on page 27, gameplay actions on page 31 and record properties on page 57. Use the PDF bookmarks to go straight to one of them.

The screenshots use PCA3D 0.86.3.4 on Linux. See the platform and release notes on page W16 for differences that matter when using another build.

Page 18 of 133Permalink
Go to page