Functions

From C4 Engine Wiki
Jump to: navigation, search

A function is a specific task exposed by a controller so that it can be invoked from a script.

Panel Controller

All of the panel controller functions have a “Target widget identifier” setting. For functions that make changes to a widget, the function is applied to all widgets in the panel whose widget identifier matches the value specified for this setting. For functions that return information about a widget, the function result corresponds to the first widget in the panel whose identifier matches the value specified for this setting, as determined by drawing order in the panel.

All widgets

The following functions affect all types of widgets.

Function Name

Description

Enable Widgets

Enables widgets in a panel, making them interactive.

Disable Widgets

Disables widgets in a panel, making them non-interactive.

Show Widgets

Shows widgets in a panel, making them visible.

Hide Widgets

Hides widgets in a panel, making them invisible.

Activate Widgets

Activates widgets in a panel as if the user had clicked on them to perform some action.

Set Mutator State

Sets the mutator state for widgets in a panel.

  • The “Target mutator identifier” setting specifies which mutators are affected. All mutators for each affected widget whose mutator identifier matches the value specified for this setting is affected.
  • The “Mutator disabled” setting specifies whether the mutator is disabled. The mutator is disabled and stops running if this box is checked.
  • The “Mutator reversed” setting specified whether the mutator runs in the reverse direction.

Get Widget Color

Returns one of the colors assigned to a widget in a panel.

  • The “Color type” setting specifies which color to return. Some color types are only supported by certain widgets. If the target widget does not support the specified color type, then the default widget color is returned.

Set Widget Color

Sets one of the colors assigned to widgets in a panel.

  • The “Widget color” setting specifies the new widget color.
  • The “Color type” setting specifies which color to set. Some color types are only supported by certain widgets. If the target widget does not support the specified color type, then the default widget color is set.


Widgets having an integer value

The following functions affect these widgets: check box, radio button, progress bar, slider, scroll bar, list box, multipane box, and popup menu.

Function Name

Description

Get Widget Value

Returns the current value of a widget in a panel.

Set Widget Value

Sets the current value of widgets in a panel.

  • The “Widget value” setting specifies the new value.


Image widgets

The following functions affect only image widgets.

Function Name

Description

Get Widget Image

Returns a string that contains the name of the texture map used by an image widget in a panel.

Set Widget Image

Sets the name of the texture map used by image widgets in a panel.

  • The “Widget texture map name” setting specifies the new name of the texture map.


Text widgets

The following functions affect only text widgets and edit text widgets.

Function Name

Description

Get Widget Text

Returns a string that contains the text used by a text widget in a panel.

Set Widget Text

Sets the text used by text widgets in a panel.

  • The “Widget text” setting specifies the new text.
  • The “Text combine mode” setting specifies how the new text is set. If this setting is “Replace”, then the old text is deleted and completely replaced by the new text. If this setting is “Append”, then the new text is added to the end of the existing text. If this setting is “Prepend”, then the new text is added to the beginning of the existing text.
  • The “Max result length” setting specifies the maximum length of the resulting text. This is used only if the text combine mode is append or prepend, and it limits the length of the combined text. If a value of 0 is specified, then there is no limit.


Camera widgets

The following functions affect only camera widgets.

Function Name

Description

Set Camera Connector Key

Sets the connector key used by camera widgets in a panel.

  • The “Camera connector key” setting specifies the new connector key attached to the panel node. This connector should be linked to a camera node, and the camera widget will begin rendering its contents through this camera node.


Paint widgets

The following functions affect only paint widgets.

Function Name

Description

Get Paint Widget Brush Radius

Returns the brush radius (as a floating-point value) used by a paint widget in a panel.

Set Paint Widget Brush Radius

Sets the brush radius used by paint widgets in a panel.

  • The “Brush radius” setting specifies the new brush radius.

Get Paint Widget Brush Fuzziness

Returns the brush fuzziness (as a floating-point value) used by a paint widget in a panel.

Set Paint Widget Brush Fuzziness

Sets the brush fuzziness used by paint widgets in a panel.

  • The “Brush fuzziness” setting specifies the new brush fuzziness.

Get Paint Widget Brush Opacity

Returns the brush opacity (as a floating-point value) used by a paint widget in a panel.

Set Paint Widget Brush Opacity

Sets the brush opacity used by paint widgets in a panel.

  • The “Brush opacity” setting specifies the new brush opacity.

Get Paint Widget Brush Color

Returns the brush color used by a paint widget in a panel.

Set Paint Widget Brush Color

Sets the brush color used by paint widgets in a panel.

  • The “Brush color” setting specifies the new brush color.


Movie widgets

The following functions affect only movie widgets.

Function Name

Description

Play Movie Widget

Plays movie widgets in a panel.

Stop Movie Widget

Stops movie widgets in a panel.

Get Movie Widget Time

Returns the current time, in floating-point seconds, for a movie widget in a panel.

Set Movie Widget Time

Sets the current time for movie widgets in a panel.

  • The “Time (sec)” setting specifies the new movie time.


Physics Controller

Function Name

Description

Set Gravity

Sets the global acceleration of gravity.

  • The “Gravity acceleration (m/s2)” setting specifies the new acceleration of gravity.


Water Controller

Function Name

Description

Generate Point Wave

Generates a wave at a single point in a water block.

  • The “Position connector key” setting specifies the key of the connector that is linked to a marker node at the position where the wave should be generated.
  • The “Generator wave radius” setting specifies the radius of the initial wave, in meters.
  • The “Height delta per step” setting specifies change in elevation, in meters, that is applied to the water surface at each time step.
  • The “Duration (time steps)” setting specifies the number of time steps over which the wave generator is applied.

Generate Line Wave

Generates a wave along a line segment in a water block.

  • The “Endpoint 1 connector key” setting specifies the key of the connector that is linked to a marker node positioned at one end of the line segment where the wave should be generated.
  • The “Endpoint 2 connector key” setting specifies the key of the connector that is linked to a marker node positioned at the other end of the line segment where the wave should be generated.
  • The “Generator wave radius” setting specifies the radius of the initial wave, in meters.
  • The “Height delta per step” setting specifies change in elevation, in meters, that is applied to the water surface at each time step.
  • The “Duration (time steps)” setting specifies the number of time steps over which the wave generator is applied.


Animation Controller

Function Name

Description

Play Animation

Plays an animation for a model.

  • The “Animation name” setting specifies the resource name of the animation to play.
  • The “Reverse” setting specifies whether the animation is initially playing in reverse.
  • The “Loop” setting specifies whether the animation is looping.
  • The “Oscillate” setting specifies whether the animation is oscillating.

Stop Animation

Stops an animation for a model.


See Also