42. Use types and return values deliberately
| Type | Suitable value / default |
|---|---|
| string | Ordinary text, such as Workshop reward. |
| int | A whole number, such as 7. |
| float | A finite number, such as 0.75. |
| bool | Boolean true or false; the caller form provides a checkbox. |
| entity | A record ID as text. The special value this resolves to the captured caller. |
| variant | A 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.
