Skip to reading
The Variable Designer

16. Use the same values in GDScript

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

Actions, visual nodes and native scripts can all use the same runtime variable store. You do not need a separate score for each language. The GDScript example on the next page performs the same one-time reward as the visual graph.

1. Open GDScript Designer, create a record with ID wind_script and give it a readable name.

2. Use the source on the next page. Keep the extends line: it supplies the PCA action helpers.

3. Click Validate, then Apply Changes, and save the project.

4. In the object’s Use actions, choose Run Visual Script and select this GDScript record in Script. That selector includes the supported script kinds despite the action’s label.

5. Replace the old implementation for this test. Start a fresh preview, use the object once, wait, and use it again.

Figure 22. The guard implemented in GDScript Designer. The full, readable source follows on the next page.

Shared variables and local variables#

A GDScript declaration such as var score = 0 inside a function creates a local value. It is not the global score record from Variable Designer. Use the PCA variable helpers, the Variable registry, or an explicit runtime read when you intend to use the shared value.

Keep global instance alive is about the lifetime of a script instance. It does not turn every script member into a designer variable or automatically save arbitrary member fields in a game slot.

Choose one implementation for a single interaction while learning. Running the visual reward and the GDScript reward as extra sequential steps makes it harder to tell which action changed the state.

Page 27 of 37Permalink
Go to page