Skip to reading
GDScript Programming & Godot

Review a GDScript declaration

Edition 0.86.4.7

0.86.4.7 tutorial edition with new lessons for Studio 0.86.4.6 and 0.86.4.7. Earlier chapters, screenshots and registry figures retain their stated edition context.

Download PDFView PDF page
PCA 3D ADVENTURE STUDIO                                                                 GDScript programming and Godot

STUDIO 0.86.4.7 • LESSON 2 OF 4

Use a tiny function that returns its input. It is easy to spot a caller that sends the wrong type or a stale argument.

1. Enter the function

In a disposable GDScript script, enter the code below. The annotations declare an integer input and return. Keep the return statement indented inside the function. Open Functions as Actions and Nodes and select the discovered tune function.

GDScript

Code example
func tune(a: int) -> int:
    return a

2. Inspect what Studio discovered

Compare the discovered parameter a and return type with the source and your intended public signature. Give it the display name Echo instrument value and category Instruments. Click Apply reviewed signature if the proposal is correct. Verify it is exposed, choose Use Definitions, and save the script.

3. Try a real caller

In an action list choose Call Script Function and select your exposed definition. Pass a fixed integer, such as 7, as the argument. Set up a regression case for the same function with Arguments [7] and Expected return 7. After the fixed case passes, use your GUI event’s numeric value as the caller’s input.

WHAT TO CHECK

If the declaration does not appear, confirm it is in the current editor text and has a supported static form. You can enter the metadata manually when using a dynamic definition. Existing callers need a separate review after a signature change.

Related original lesson | p. 61 Tutorial edition 0.86.4.7

Page 380 of 382Permalink
Go to page