Module ManualSwitchUnit

A manual switch that can be in an on/off state.

Element class: ManualSwitchUnit

Extends: Element > ElementWithState > ElementWithToggle

Functions

activate () Switches the switch on.
deactivate () Switches the switch off.
isActive () Checks if the switch is active.
setSignalIn (plug, state) Set the value of a signal in the specified IN plug of the element.
getSignalIn (plug) Return the value of a signal in the specified IN plug of the element.
getSignalOut (plug) Return the value of a signal in the specified OUT plug of the element.
EVENT_pressed () Deprecated: Event: The button has been pressed.
EVENT_onPressed () Event: Emitted when the button is pressed.
EVENT_released () Deprecated: Event: The button has been released.
EVENT_onReleased () Event: Emitted when the button is released.
mockRegisterPressed (callback) Mock only, not in-game: Register a handler for the in-game `pressed()` event.
mockDoPressed () Mock only, not in-game: Simulates the user pressing the button.
mockRegisterReleased (callback) Mock only, not in-game: Register a handler for the in-game `released()` event.
mockDoReleased () Mock only, not in-game: Simulates the user releasing the button.
mockGetClosure () Mock only, not in-game: Bundles the object into a closure so functions can be called with "." instead of ":".


Functions

activate ()
Switches the switch on.
deactivate ()
Switches the switch off.
isActive ()
Checks if the switch is active.

Returns:

    0/1 1 if the switch is active.
setSignalIn (plug, state)
Set the value of a signal in the specified IN plug of the element.

Valid plug names are:

  • "on" for the in signal (seems to have no actual effect when modified this way).

Parameters:

  • plug string A valid plug name to set.
  • state 0/1 The plug signal state
getSignalIn (plug)
Return the value of a signal in the specified IN plug of the element.

Valid plug names are:

  • "on" for the in signal.

Parameters:

  • plug string A valid plug name to query.

Returns:

    0/1 The plug signal state
getSignalOut (plug)
Return the value of a signal in the specified OUT plug of the element.

Valid plug names are:

  • "out" for the out signal.

Parameters:

  • plug string A valid plug name to query.

Returns:

    0/1 The plug signal state
EVENT_pressed ()
Deprecated: Event: The button has been pressed.

Note: This is documentation on an event handler, not a callable method.

This event is deprecated: EVENT_onPressed should be used instead.

See also:

EVENT_onPressed ()
Event: Emitted when the button is pressed.

Note: This is documentation on an event handler, not a callable method.

EVENT_released ()
Deprecated: Event: The button has been released.

Note: This is documentation on an event handler, not a callable method.

This event is deprecated: EVENT_onReleased should be used instead.

See also:

EVENT_onReleased ()
Event: Emitted when the button is released.

Note: This is documentation on an event handler, not a callable method.

mockRegisterPressed (callback)
Mock only, not in-game: Register a handler for the in-game `pressed()` event.

Parameters:

  • callback function The function to call when the button is pressed.

Returns:

    int The index of the callback.

See also:

mockDoPressed ()
Mock only, not in-game: Simulates the user pressing the button. This is not triggered by calls to `activate()` or `toggle()`. Calling this while the button is already deactivated is invalid and will have no effect.

Note: the state updates to true before the event handlers are called, which is different behavior to releasing the button.

mockRegisterReleased (callback)
Mock only, not in-game: Register a handler for the in-game `released()` event.

Parameters:

  • callback function The function to call when the button is released.

Returns:

    int The index of the callback.

See also:

mockDoReleased ()
Mock only, not in-game: Simulates the user releasing the button. This is not triggered by calls to `deactivate()` or `toggle()`. Calling this while the button is already deactivated is invalid and will have no effect.

Note: the state updates to true after the event handlers are called, which is different behavior to pressing the button.

mockGetClosure ()
Mock only, not in-game: Bundles the object into a closure so functions can be called with "." instead of ":".

Returns:

    table A table encompasing the api calls of object.

See also:

generated by LDoc 1.5.0 Last updated 2024-09-27 15:22:46