52. Expose a native function as a visual node
func award(points: int, message: String = "Well done.") -> int:
var updated: int = int(Variable.score.value) + points
Variable.score.value = updated
Log(message)
return updated1. Create a native script reward_gd with this function. Validate and Apply Changes.
2. Open Functions as Nodes. Add a function definition named award and a useful display name.
3. Add points as int, then message as string, in the same order as the source. Enter defaults that match those types. Check Expose as Action and Visual Node.
4. Click Use Definitions to accept the metadata, then Apply Changes to save the script.
5. In a visual script or supported action list, add Call Script Function, choose the published function, fill in the parameters and optionally select a result variable.
Figure 17. The exposed function definition describes the source function’s parameter contract.
