Skip to content
Lukas Sägesser edited this page Jun 22, 2015 · 12 revisions

Object

####Category: Core

Brief Description

Base class for all non built-in types.

Member Functions

Signals

  • script_changed ( )

Numeric Constants

  • NOTIFICATION_POSTINITIALIZE = 0 - Called right when the object is initialized. Not available in script.
  • NOTIFICATION_PREDELETE = 1 - Called before the object is about to be deleted.
  • CONNECT_DEFERRED = 1 - Connect a signal in deferred mode. This way, signal emissions are stored in a queue, then set on idle time.
  • CONNECT_PERSIST = 2 - Persisting connections are saved when the object is serialized to file.
  • CONNECT_ONESHOT = 4 - One short connections disconnect themselves after emission.

Description

Base class for all non built-in types. Everything not a built-in type starts the inheritance chain from this class. Objects do not manage memory, if inheriting from one the object will most likely have to be deleted manually (call the free function from the script or delete from C++). Some derivates add memory management, such as Reference (which keps a reference count and deletes itself automatically when no longer referenced) and Node, which deletes the children tree when deleted. Objects export properties, which are mainly useful for storage and editing, but not really so much in programming. Properties are exported in _get_property_list and handled in _get and [_set]. However, scripting languages and C++ have simper means to export them. Objects also receive notifications (_notification). Notifications are a simple way to notify the object about simple events, so they can all be handled together.

Member Function Description

  • void _get ( String property ) virtual

Return a property, return null if the property does not exist.

  • Array _get_property_list ( ) virtual

Return the property list, array of dictionaries, dictionaries must countain: name:String, type:int (see TYPE_* enum in globals) and optionally: hint:int (see PROPERTY_HINT_* in globals), hint_string:String, usage:int (see PROPERTY_USAGE_* in globals).

  • void _notification ( int what ) virtual

Notification request, the notification id is received.

  • void _set ( String property, var value ) virtual

Set a property. Return true if the property was found.

Return the type of the object as a string.

Check the type of the obeject against a string (including inheritance).

  • void set ( String property, var value )

Set property into the object.

  • void get ( String property ) const

Get a property from the object.

  • Array get_property_list ( ) const

Return the list of properties as an array of dictionaries, dictionaries countain: name:String, type:int (see TYPE_* enum in globals) and optionally: hint:int (see PROPERTY_HINT_* in globals), hint_string:String, usage:int (see PROPERTY_USAGE_* in globals).

  • void notification ( int what, bool arg1=false )

Notify the object of something.

  • int get_instance_ID ( ) const

Return the instance ID. All objects have a unique instance ID.

  • void set_script ( Script script )

Set a script into the object, scripts extend the object functionality.

Return the object script (or null if it doesn't have one).

  • void set_meta ( String name, var value )

Set a metadata into the object. Medatada is serialized. Metadata can be anything.

  • void get_meta ( String name ) const

Return a metadata from the object.

Return true if a metadata is found with the requested name.

Return the list of metadatas in the object.

  • void add_user_signal ( String signal, Array arguments=Array() )

Add a user signal (can be added anytime). Arguments are optional, but can be added as an array of dictionaries, each containing "name" and "type" (from [@GlobalScope] TYPE_*).

  • void emit_signal ( String signal, var arg0=NULL, var arg1=NULL, var arg2=NULL, var arg3=NULL, var arg4=NULL )

Emit a signal. Arguments are passed in an array.

  • void call ( String method, var arg0=NULL, var arg1=NULL, var arg2=NULL, var arg3=NULL, var arg4=NULL, var arg5=NULL, var arg6=NULL, var arg7=NULL, var arg8=NULL, var arg9=NULL )

Call a function in the object, result is returned.

  • void call_deferred ( String method, var arg0=NULL, var arg1=NULL, var arg2=NULL, var arg3=NULL, var arg4=NULL )

Create and store a function in the object. The call will take place on idle time.

  • Array get_signal_list ( ) const

Return the list of signals as an array of dictionaries.

Connect a signal to a method at a target (member function). Binds are optional and are passed as extra arguments to the call. Flags specify optional deferred or one shot connections, see enum CONNECT_*. A signal can only be connected once to a method, and it will throw an error if already connected. If you want to avoid this, use is_connected to check.

Disconnect a signal from a method.

Return true if a connection exists for a given signal and target/method.

  • void set_block_signals ( bool enable )

If set to true, signal emission is blocked.

  • bool is_blocking_signals ( ) const

Return true if signal emission blocking is enabled.

  • void set_message_translation ( bool enable )

Set true if this object can translate strings (in calls to tr() ). Default is true.

  • bool can_translate_messages ( ) const

Return true if this object can translate strings.

deprecated, will go away.

Translate a message. Only works in message translation is enabled (which is by default). See set_message_translation.

Clone this wiki locally