VisualScript

Inherits: Script < Resource < RefCounted < Object

A script implemented in the Visual Script programming environment.

Description

A script implemented in the Visual Script programming environment. The script extends the functionality of all objects that instance it.

Object.set_script extends an existing object, if that object's class matches one of the script's base classes.

You are most likely to use this class via the Visual Script editor or when writing plugins for it.

Tutorials

Methods

void

add_custom_signal ( StringName name )

void

add_function ( StringName name, int func_node_id )

void

add_node ( int id, VisualScriptNode node, Vector2 position=Vector2(0, 0) )

void

add_variable ( StringName name, Variant default_value=null, bool export=false )

void

custom_signal_add_argument ( StringName name, Variant.Type type, String argname, int index=-1 )

int

custom_signal_get_argument_count ( StringName name ) const

String

custom_signal_get_argument_name ( StringName name, int argidx ) const

Variant.Type

custom_signal_get_argument_type ( StringName name, int argidx ) const

void

custom_signal_remove_argument ( StringName name, int argidx )

void

custom_signal_set_argument_name ( StringName name, int argidx, String argname )

void

custom_signal_set_argument_type ( StringName name, int argidx, Variant.Type type )

void

custom_signal_swap_argument ( StringName name, int argidx, int withidx )

void

data_connect ( int from_node, int from_port, int to_node, int to_port )

void

data_disconnect ( int from_node, int from_port, int to_node, int to_port )

int

get_function_node_id ( StringName name ) const

VisualScriptNode

get_node ( int id ) const

Vector2

get_node_position ( int id ) const

Vector2

get_scroll ( ) const

Variant

get_variable_default_value ( StringName name ) const

bool

get_variable_export ( StringName name ) const

Dictionary

get_variable_info ( StringName name ) const

bool

has_custom_signal ( StringName name ) const

bool

has_data_connection ( int from_node, int from_port, int to_node, int to_port ) const

bool

has_function ( StringName name ) const

bool

has_node ( int id ) const

bool

has_sequence_connection ( int from_node, int from_output, int to_node ) const

bool

has_variable ( StringName name ) const

void

remove_custom_signal ( StringName name )

void

remove_function ( StringName name )

void

remove_node ( int id )

void

remove_variable ( StringName name )

void

rename_custom_signal ( StringName name, StringName new_name )

void

rename_function ( StringName name, StringName new_name )

void

rename_variable ( StringName name, StringName new_name )

void

sequence_connect ( int from_node, int from_output, int to_node )

void

sequence_disconnect ( int from_node, int from_output, int to_node )

void

set_instance_base_type ( StringName type )

void

set_node_position ( int id, Vector2 position )

void

set_scroll ( Vector2 offset )

void

set_variable_default_value ( StringName name, Variant value )

void

set_variable_export ( StringName name, bool enable )

void

set_variable_info ( StringName name, Dictionary value )

Signals

  • node_ports_changed ( int id )

Emitted when the ports of a node are changed.

Method Descriptions

Add a custom signal with the specified name to the VisualScript.


Add a function with the specified name to the VisualScript, and assign the root VisualScriptFunction node's id as func_node_id.


Add a node to the VisualScript.


Add a variable to the VisualScript, optionally giving it a default value or marking it as exported.


Add an argument to a custom signal added with add_custom_signal.


Get the count of a custom signal's arguments.


Get the name of a custom signal's argument.


Get the type of a custom signal's argument.


  • void custom_signal_remove_argument ( StringName name, int argidx )

Remove a specific custom signal's argument.


Rename a custom signal's argument.


Change the type of a custom signal's argument.


Swap two of the arguments of a custom signal.


  • void data_connect ( int from_node, int from_port, int to_node, int to_port )

Connect two data ports. The value of from_node's from_port would be fed into to_node's to_port.


  • void data_disconnect ( int from_node, int from_port, int to_node, int to_port )

Disconnect two data ports previously connected with data_connect.


Returns the id of a function's entry point node.


Returns a node given its id.


Returns a node's position in pixels.


Returns the current position of the center of the screen.


Returns the default (initial) value of a variable.


Returns whether a variable is exported.


Returns the information for a given variable as a dictionary. The information includes its name, type, hint and usage.


Returns whether a signal exists with the specified name.


  • bool has_data_connection ( int from_node, int from_port, int to_node, int to_port ) const

Returns whether the specified data ports are connected.


Returns whether a function exists with the specified name.


Returns whether a node exists with the given id.


  • bool has_sequence_connection ( int from_node, int from_output, int to_node ) const

Returns whether the specified sequence ports are connected.


Returns whether a variable exists with the specified name.


Remove a custom signal with the given name.


Remove a specific function and its nodes from the script.


  • void remove_node ( int id )

Remove the node with the specified id.


Remove a variable with the given name.


Change the name of a custom signal.


Change the name of a function.


Change the name of a variable.


  • void sequence_connect ( int from_node, int from_output, int to_node )

Connect two sequence ports. The execution will flow from of from_node's from_output into to_node.

Unlike data_connect, there isn't a to_port, since the target node can have only one sequence port.


  • void sequence_disconnect ( int from_node, int from_output, int to_node )

Disconnect two sequence ports previously connected with sequence_connect.


Set the base type of the script.


  • void set_node_position ( int id, Vector2 position )

Set the node position in the VisualScript graph.


  • void set_scroll ( Vector2 offset )

Set the screen center to the given position.


Change the default (initial) value of a variable.


Change whether a variable is exported.


Set a variable's info, using the same format as get_variable_info.