Struct Script

A class stored as a resource.

struct Script ;

A script extends the functionality of all objects that instance it. The new method of a script subclass creates a new instance. GodotObject.setScript extends an existing object, if that object's class matches one of the script's base classes.

Properties

NameTypeDescription
sourceCode[get, set] StringThe script source code or an empty string if source code is not available. When set, does not reload the class implementation automatically.

Methods

NameDescription
canInstance Returns true if the script can be instanced.
getBaseScript Returns the script directly inherited by this script.
getInstanceBaseType Returns the script's base type.
getPropertyDefaultValue
getScriptConstantMap
getScriptMethodList
getScriptPropertyList
getScriptSignalList
getSourceCode
hasScriptSignal Returns true if the script, or a base class, defines a signal with the given name.
hasSourceCode Returns true if the script contains non-empty source code.
instanceHas Returns true if base_object is an instance of this script.
isTool Returns true if the script is a tool script. A tool script can run in the editor.
reload Reloads the script's class implementation. Returns an error code.
setSourceCode