Skip to reading
GDScript Programming & Godot

CallScriptFunction()

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 PDF page

Call Script Function

Call a function published through Functions as Nodes, pass named parameters, and optionally store its return value.

Source table from CallScriptFunction(), page 93
Option key / fieldMeaning and inputDefault
Function functionKeyText/reference.Blank
Parameters parametersA typed value or valid JSON.{}
Result Variable resultVariableName of the game variable that receives the returned value.Blank

Timing. Waits for the published function call.

Code example
await CallScriptFunction({
    "functionKey": "scripts/reward_gd/award",
    "parameters": {"points": 5, "message": "Well done."},
    "resultVariable": ""
})

In use. Publish a reward function with points and message parameters. Choose it here, enter those parameters, and store the result in reward_ok. The function must be defined and published first; this action does not infer a function from an arbitrary name.

Page 93 of 378Permalink
Go to page