Skip to reading
Visual Scripting in Depth

42. Use types and return values deliberately

Edition 0.86.4.3

0.86.4.3 edition with revised lessons, updated cross-references and new cinematic/camera-safety supplements. Earlier examples, screenshots and registry figures retain their stated edition context.

Download PDFView PDF page
Source table from 42. Use types and return values deliberately, page 46
TypeSuitable value / default
stringOrdinary text, such as Workshop reward.
intA whole number, such as 7.
floatA finite number, such as 0.75.
boolBoolean true or false; the caller form provides a checkbox.
entityA record ID as text. The special value this resolves to the captured caller.
variantA JSON-compatible value, including an array, dictionary or null.

Set the parameter type before entering its default. Changing the type resets that default to the new type’s initial value. In the definition window, numeric, Boolean and variant defaults use JSON values; string and entity defaults use ordinary text.

1. Decide which inputs the function genuinely needs.

2. Give each parameter a valid, unique name.

3. Choose its type, then enter a sensible default.

4. Use Return for a deliberate result.

5. Store the result only when the caller will use it.

6. Check that any later comparison expects the actual return type.

A destination runtime variable can receive a compound result. For example, describe returns a dictionary containing amount and label. Do not compare that whole dictionary directly with the number 7 and expect it to match.

An entity parameter is an ID, not a preloaded Godot node. Resolve or pass that ID through PCA’s record/action APIs. Its spelling and availability still matter.

Page 46 of 93Permalink
Go to page