Skip to reading
Lua Scripting

How a button finds a Lua record

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 illustrations

GUI EVENTS

The word on a button tells the player what to expect. Its Click Target tells PCA3D which script should do the work.

The highlighted item is a button named Check       In this screenshot its Click Target is archive_unlock.
Answer.

01. Select a button in GUI Designer → GUI Elements. In the right Inspector, open Element Properties → Events. On smaller screens, use the tab arrows to reach Events.

02. Find Click. In 0.86.3.4 the behavior named run-visual-script also starts Lua records. Enter your Lua record’s ID under Click Target.

03. To tell whether a click reaches the record, put a short Log call at the beginning of its run function. Apply the record, save your game and click the button in the game preview.

Code example
Log("The button reached this script.")

If moving the pointer starts the script, inspect the Hover setting above Click. Those two events can have different behaviors.

Lua scripting   /   Illustrated guide                                                          W10
Page 10 of 133Permalink
Go to page