12. Dialogue, messages and sound
12. Dialogue, messages and sound
6. In an action list or visual graph, add Call Script Function. Select the script, language and function. Its named parameter fields should now appear.
Use Definitions is a commit button for the definitions you have just edited. It does not create a graph in the background or run the function. If it appears to do nothing, check that you added a definition, accepted it, applied the script and selected Call Script Function in the destination editor.
Definitions describe code; they do not rewrite a function's signature. If you rename or reorder parameters, update the source and definition together. Result Variable is optional and receives the function's return value.
What this means in a script#
this refers to the object or record whose event called the script. A shared door script can read this.id rather than containing one particular door ID. GDScript self still means the script instance. It is not a replacement for the game object's this.
A startup action may have no calling object. Check this before reading it in code that can also run without an owner. In visual/action target fields, choose this when the action should affect its caller. A scene change does not turn an existing caller into a different object.
func describe(amount, label):
var owner_name = this.name if this != null else "No caller"
return {"owner": owner_name, "value": amount, "label": label}Expose describe with amount as int, default 7, and label as string, default Hello. Call it from an object's event, store the result if needed, and inspect the output. This is a useful first function because it proves both parameters and caller identity before it changes the game.
Dialogue Designer builds conversations as a graph. A Line displays speech, a Choice offers responses, an Action changes the game and an End closes the conversation. Connect outputs to destinations, then set the intended first node as Start.
