Skip to reading
PCA Script Programming

2. Your first script in the editor

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

1. Open a game project. In the Adventure Database, add a PCA Script record and select it. The PCA Script workspace opens. If the database is hidden, restore it through the Panels controls.

2. Give the script an ID such as hello_pca and a name such as First Greeting. An ID is the stable name other records use to call it.

3. Replace the source with the example below. Click Validate. A clean result should say there are no errors or warnings.

4. Click Apply Changes. Save the project. Start Test Scene or Play so that a running game exists, then use Run to try the script. A gameplay instruction needs that runtime.

Code example
language 1.0
Code example
function run()
    log("Hello from PCA Script.")
    show_message({"text": "Welcome to the workshop.", "duration": 2})
end

Figure 2. A PCA Script record in the editor, with source, validation results and the script toolbar.

Keep IDs unique across scripting languages. hello_pca should not also be the ID of a Lua or visual script. A visible Name (ID) label is convenient, but the ID is what the router needs.

Page 9 of 357Permalink
Go to page