Script

package
v0.0.0-...-f3deeb4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package Script provides methods for working with Script object instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsScript() Instance
}

type Instance

type Instance [1]gdclass.Script

A class stored as a resource. A script extends the functionality of all objects that instantiate it. This is the base class for all scripts and should not be used directly. Trying to create a new script with this class will result in an error. The [code]new[/code] method of a script subclass creates a new instance. [method Object.set_script] extends an existing object, if that object's class matches one of the script's base classes.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) AsScript

func (self Instance) AsScript() Instance

func (Instance) CanInstantiate

func (self Instance) CanInstantiate() bool

Returns [code]true[/code] if the script can be instantiated.

func (Instance) GetBaseScript

func (self Instance) GetBaseScript() [1]gdclass.Script

Returns the script directly inherited by this script.

func (Instance) GetGlobalName

func (self Instance) GetGlobalName() string

Returns the class name associated with the script, if there is one. Returns an empty string otherwise. To give the script a global name, you can use the [code]class_name[/code] keyword in GDScript and the [code][GlobalClass][/code] attribute in C#. [codeblocks] [gdscript] class_name MyNode extends Node [/gdscript] [csharp] using Godot;

[GlobalClass] public partial class MyNode : Node { } [/csharp] [/codeblocks]

func (Instance) GetInstanceBaseType

func (self Instance) GetInstanceBaseType() string

Returns the script's base type.

func (Instance) GetPropertyDefaultValue

func (self Instance) GetPropertyDefaultValue(property string) any

Returns the default value of the specified property.

func (Instance) GetScriptConstantMap

func (self Instance) GetScriptConstantMap() map[string]interface{}

Returns a dictionary containing constant names and their values.

func (Instance) GetScriptMethodList

func (self Instance) GetScriptMethodList() []PropertyInfo

Returns the list of methods in this [Script].

func (Instance) GetScriptPropertyList

func (self Instance) GetScriptPropertyList() []PropertyInfo

Returns the list of properties in this [Script].

func (Instance) GetScriptSignalList

func (self Instance) GetScriptSignalList() []SignalInfo

Returns the list of user signals defined in this [Script].

func (Instance) HasScriptSignal

func (self Instance) HasScriptSignal(signal_name string) bool

Returns [code]true[/code] if the script, or a base class, defines a signal with the given name.

func (Instance) HasSourceCode

func (self Instance) HasSourceCode() bool

Returns [code]true[/code] if the script contains non-empty source code. [b]Note:[/b] If a script does not have source code, this does not mean that it is invalid or unusable. For example, a [GDScript] that was exported with binary tokenization has no source code, but still behaves as expected and could be instantiated. This can be checked with [method can_instantiate].

func (Instance) InstanceHas

func (self Instance) InstanceHas(base_object Object.Instance) bool

Returns [code]true[/code] if [param base_object] is an instance of this script.

func (Instance) IsAbstract

func (self Instance) IsAbstract() bool

Returns [code]true[/code] if the script is an abstract script. An abstract script does not have a constructor and cannot be instantiated.

func (Instance) IsTool

func (self Instance) IsTool() bool

Returns [code]true[/code] if the script is a tool script. A tool script can run in the editor.

func (Instance) Reload

func (self Instance) Reload() error

Reloads the script's class implementation. Returns an error code.

func (Instance) SetSourceCode

func (self Instance) SetSourceCode(value string)

func (Instance) SourceCode

func (self Instance) SourceCode() string

func (*Instance) UnsafePointer

func (self *Instance) UnsafePointer() unsafe.Pointer

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type PropertyInfo

type PropertyInfo struct {
	ClassName  string       `gd:"class_name"`
	Name       string       `gd:"name"`
	Hint       int          `gd:"hint"`
	HintString string       `gd:"hint_string"`
	Type       reflect.Type `gd:"type"`
	Usage      int          `gd:"usage"`
}

type SignalInfo

type SignalInfo struct {
	Name        string         `gd:"name"`
	Flags       int            `gd:"flags"`
	ID          int            `gd:"id"`
	DefaultArgs []interface{}  `gd:"default_args"`
	Args        []PropertyInfo `gd:"args"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL