.. default-domain:: lua .. highlight:: lua .. currentmodule:: SpaceCenter Alarms ====== .. class:: AlarmManager Alarm manager. Obtained by calling :attr:`SpaceCenter.alarm_manager `. .. attribute:: alarms: List A list of all alarms. :Attribute: Read-only, cannot be set :rtype: List .. method:: alarms_with_type(type) A list of all alarms of the given type. :param SpaceCenter.AlarmType type: The type of alarm to return. :rtype: List .. method:: alarm_with_name(name) Returns the first alarm with the given title, or ``nil`` if no such alarm exists. Alarm titles are not guaranteed to be unique; if more than one alarm shares the given title, the first one found is returned. :param string name: The title of the alarm to return. :rtype: :class:`SpaceCenter.Alarm` .. staticmethod:: add_alarm(time, [title = 'Alarm'], [description = '']) Create an alarm. :param number time: Number of seconds from now that the alarm should trigger. :param string title: Title for the alarm. :param string description: Description for the alarm. :rtype: :class:`SpaceCenter.Alarm` .. staticmethod:: add_vessel_alarm(time, vessel, [title = 'Vessel Alarm'], [description = '']) Create an alarm linked to a vessel. :param number time: Number of seconds from now that the alarm should trigger. :param SpaceCenter.Vessel vessel: Vessel to link the alarm to. :param string title: Title for the alarm. :param string description: Description for the alarm. :rtype: :class:`SpaceCenter.Alarm` .. staticmethod:: add_apoapsis_alarm(vessel, [offset = 60.0], [title = 'Apoapsis Alarm'], [description = '']) Create an alarm for the given vessel's next apoapsis. :param SpaceCenter.Vessel vessel: The vessel. :param number offset: Time in seconds to offset the alarm by. :param string title: Title for the alarm. :param string description: Description for the alarm. :rtype: :class:`SpaceCenter.Alarm` .. staticmethod:: add_periapsis_alarm(vessel, [offset = 60.0], [title = 'Periapsis Alarm'], [description = '']) Create an alarm for the given vessel's next periapsis. :param SpaceCenter.Vessel vessel: The vessel. :param number offset: Time in seconds to offset the alarm by. :param string title: Title for the alarm. :param string description: Description for the alarm. :rtype: :class:`SpaceCenter.Alarm` .. staticmethod:: add_maneuver_node_alarm(vessel, node, [offset = 60.0], [add_burn_time = True], [title = 'Maneuver Node Alarm'], [description = '']) Create an alarm for the given vessel and maneuver node. :param SpaceCenter.Vessel vessel: The vessel. :param SpaceCenter.Node node: The maneuver node. :param number offset: Time in seconds to offset the alarm by. :param boolean add_burn_time: Whether the node's burn time should be included in the alarm. :param string title: Title for the alarm. :param string description: Description for the alarm. :rtype: :class:`SpaceCenter.Alarm` .. staticmethod:: add_soi_alarm(vessel, [offset = 60.0], [title = 'SOI Change Alarm'], [description = '']) Create an alarm for the given vessel's next sphere of influence change. :param SpaceCenter.Vessel vessel: The vessel. :param number offset: Time in seconds to offset the alarm by. :param string title: Title for the alarm. :param string description: Description for the alarm. :rtype: :class:`SpaceCenter.Alarm` .. staticmethod:: add_transfer_window_alarm(vessel, target, [title = 'Transfer Window Alarm'], [description = '']) Create an alarm for the next planetary transfer window from the vessel's current parent body to the target body. :param SpaceCenter.Vessel vessel: The vessel. :param SpaceCenter.CelestialBody target: The target body. :param string title: Title for the alarm. :param string description: Description for the alarm. :rtype: :class:`SpaceCenter.Alarm` .. note:: This relies on KSP's stock transfer-window alarm logic. If KSP cannot compute a transfer from the vessel's current parent body to the target, the resulting alarm may not fire at a useful time; in that case the properties on the returned alarm can still be used to inspect or adjust it. .. class:: Alarm An alarm. Can be accessed using :attr:`SpaceCenter.alarm_manager `. .. attribute:: id: number Unique identifier of the alarm. KSP destroys and recreates an alarm when it is edited. This id will remain constant between the old and new alarms. :Attribute: Read-only, cannot be set :rtype: number .. attribute:: type: SpaceCenter.AlarmType Type of alarm. :Attribute: Read-only, cannot be set :rtype: :class:`SpaceCenter.AlarmType` .. attribute:: title: string Title of the alarm. :Attribute: Can be read or written :rtype: string .. attribute:: description: string Description of the alarm. :Attribute: Can be read or written :rtype: string .. attribute:: time: number Time the alarm will trigger, in seconds since epoch. :Attribute: Can be read or written :rtype: number .. attribute:: time_until: number Time until the alarm triggers, in seconds. :Attribute: Read-only, cannot be set :rtype: number .. attribute:: event_offset: number Seconds between the alarm going off and the event it references. :Attribute: Can be read or written :rtype: number .. attribute:: vessel: SpaceCenter.Vessel Vessel the alarm references. ``nil`` if it does not reference a vessel. :Attribute: Read-only, cannot be set :rtype: :class:`SpaceCenter.Vessel` .. attribute:: node: SpaceCenter.Node Maneuver node the alarm references. Only valid for alarms of type :attr:`SpaceCenter.AlarmType.maneuver`. :Attribute: Can be read or written :rtype: :class:`SpaceCenter.Node` .. note:: Throws an exception if the alarm is not of type :attr:`SpaceCenter.AlarmType.maneuver`. .. attribute:: origin_body: SpaceCenter.CelestialBody Origin body for the transfer window. Only valid for alarms of type :attr:`SpaceCenter.AlarmType.transfer_window`. :Attribute: Can be read or written :rtype: :class:`SpaceCenter.CelestialBody` .. note:: Throws an exception if the alarm is not of type :attr:`SpaceCenter.AlarmType.transfer_window`. .. attribute:: destination_body: SpaceCenter.CelestialBody Destination body for the transfer window. Only valid for alarms of type :attr:`SpaceCenter.AlarmType.transfer_window`. :Attribute: Can be read or written :rtype: :class:`SpaceCenter.CelestialBody` .. note:: Throws an exception if the alarm is not of type :attr:`SpaceCenter.AlarmType.transfer_window`. .. attribute:: warp_action: SpaceCenter.AlarmWarpAction The action taken on time warp when the alarm fires. :Attribute: Can be read or written :rtype: :class:`SpaceCenter.AlarmWarpAction` .. attribute:: message_action: SpaceCenter.AlarmMessageAction The on-screen message behavior when the alarm fires. :Attribute: Can be read or written :rtype: :class:`SpaceCenter.AlarmMessageAction` .. attribute:: play_sound: boolean Whether the alarm plays a sound when it fires. :Attribute: Can be read or written :rtype: boolean .. attribute:: delete_on_dismiss: boolean Whether the alarm is deleted automatically once the player has dismissed the triggered message. :Attribute: Can be read or written :rtype: boolean .. attribute:: triggered: boolean Whether the time of the alarm has passed and its actions have been triggered. :Attribute: Read-only, cannot be set :rtype: boolean .. attribute:: actioned: boolean Whether the alarm's actions were triggered and then completed or closed. :Attribute: Read-only, cannot be set :rtype: boolean .. method:: remove() Removes the alarm. .. class:: AlarmType The type of an alarm. See :attr:`SpaceCenter.Alarm.type`. .. data:: raw An alarm for a specific date/time or a specific period in the future. .. data:: apoapsis An alarm for the next apoapsis of a vessel. .. data:: periapsis An alarm for the next periapsis of a vessel. .. data:: maneuver An alarm based on a maneuver node on the vessel's flight path. .. data:: soi_change An alarm for the next sphere of influence change on the vessel's flight path. .. data:: transfer_window An alarm for the next planetary transfer window from the vessel's current orbit to a target body. .. data:: unknown The alarm is of a type not recognized by kRPC. Typically this is a type introduced by a mod. .. class:: AlarmWarpAction The warp action taken when an alarm fires. See :attr:`SpaceCenter.Alarm.warp_action`. .. data:: no_change Do not change time warp when the alarm fires. .. data:: stop_warp Drop out of time warp when the alarm fires. .. data:: pause_game Pause the game when the alarm fires. .. class:: AlarmMessageAction The on-screen message action taken when an alarm fires. See :attr:`SpaceCenter.Alarm.message_action`. .. data:: no_message Do not display a message when the alarm fires. .. data:: message Display a message when the alarm fires. .. data:: message_if_not_active_vessel Display a message only if the alarm's vessel is not the currently active vessel.