ComputerObjectBase

Shared base class that any object module requires in order to function. Overriding methods from this class is possible as with any other PAYDAY 2 class; use {Module name}.super.{ComputerObjectBase method}(self, ...) to refer back to this class.

Tweak data values

{
    config = {},
    events = {},
    mouse_variant = "arrow"
}
  • config: A table containing the values that will be passed to Diesel to create interface objects. A malformed configuration table will crash the game with an access violation. You can use computed properties here to inherit config values from parent objects (see below). to be contained in ComputerWindow instances.
  • events: The events table. See Events.
  • mouse_variant: Determines what texture rect the mouse texture should have when over the object. Possible values are arrow (default), link, hand and grab; you can define more at ComputerGui.mouse_variants.

ComputerWindow instances have some more entries in addition to the previous values. See their tweak data configuration guide.

Methods

ComputerObjectBase:create()

Adds a reference to its parent and the extension instance, then computes config properties with self:compute_properties(). Modules need to refer to this method when running their create() method before doing any additional creation.

ComputerObjectBase:post_create()

Sets up the events after all the objects are created for proper callbacks.

ComputerObjectBase:setup_events()

Sets up possible events of type callback (implemented) or spawn (not implemented).

ComputerObjectBase:compute_properties()

Runs function-type properties inside config by passing self as the first argument and sets those properties to the functions' return values. This can be useful to inherit parent object values. An example of a computed property would be:

w = function(self)
    return self._parent._tweak_data.config.w - 35
end

ComputerObjectBase:trigger_event(event_name, ...)

Triggers the corresponding event on itself and passes any extra arguments to the corresponding handler.

ComputerObjectBase:is_visible(x, y)

Returns whether the object is visible at position (x, y) or not, that is, it is not obscured by windows and it itself is visible (through Object:visible()).

ComputerObjectBase:mouse_variant()

Returns the provided mouse_variant.

ComputerObjectBase:object()

Returns the Diesel object.

ComputerObjectBase:children()

Returns the instance's children instances.

Values

self._parent

Returns the parent ComputerWindow.