ksp::game

Collection to game and runtime related functions.

Types

EventProcessStarted

Process started event will be published to message bus when a process is started

Fields

Name

Type

Read-only

Description

arguments

string[]

R/O

Process start arguments

name

string

R/O

Process name

EventProcessStopped

Process stop event will be published to message bus when a process is stopped

Fields

Name

Type

Read-only

Description

error

Option<string>

R/O

Error message in case of abnormal termination

name

string

R/O

Process name

Importance

Importance of a notification

Methods

to_string
importance.to_string ( ) -> string

String representation of the number

ImportanceConstants

Fields

Name

Type

Read-only

Description

High

ksp::game::Importance

R/O

High

Low

ksp::game::Importance

R/O

Low

Medium

ksp::game::Importance

R/O

Medium

None

ksp::game::Importance

R/O

Methods

from_string
importanceconstants.from_string ( value : string ) -> Option<ksp::game::Importance>

Parse from string

Parameters

Name

Type

Optional

Description

value

string

Enum value to lookup

Mainframe

Fields

Name

Type

Read-only

Description

available_processes

ksp::game::Process[]

R/O

version

string

R/O

Version number of the KontrolSystem

Methods

find_process
mainframe.find_process ( name : string ) -> Option<ksp::game::Process>

Parameters

Name

Type

Optional

Description

name

string

MessageBus

Shared message bus

Methods

publish
messagebus.publish ( message : T ) -> Unit

Publish a message to anyone interested (or the void)

Parameters

Name

Type

Optional

Description

message

T

subscribe
messagebus.subscribe ( ) -> ksp::game::Subscription<T>

Create a subscription to a specific message type

Process

Fields

Name

Type

Read-only

Description

arguments

ksp::game::ProcessArgument[]

R/O

is_running

bool

R/O

name

string

R/O

Methods

start
process.start ( forVessel : Option<ksp::vessel::Vessel>,
                arguments : string[] ) -> bool

Parameters

Name

Type

Optional

Description

forVessel

Optionksp::vessel::Vessel

x

arguments

string[]

x

stop
process.stop ( ) -> bool

ProcessArgument

Fields

Name

Type

Read-only

Description

default_value

string

R/O

name

string

R/O

type

string

R/O

Subscription

Central message bus

Fields

Name

Type

Read-only

Description

has_messages

bool

R/O

Check if subscription has pending messages

Methods

peek
subscription.peek ( ) -> Option<T>

Peek for next message without consuming it

recv
subscription.recv ( ) -> Option<T>

Receive next message

unsubscribe
subscription.unsubscribe ( ) -> Unit

Unsubscribe from the message bus. No further messages will be received

Constants

Name

Type

Description

Importance

ksp::game::ImportanceConstants

Importance of a notification

MAINFRAME

ksp::game::Mainframe

KontrolSystem mainframe

MESSAGE_BUS

ksp::game::MessageBus

Shared message bus

Functions

current_time

pub sync fn current_time ( ) -> float

Get the current universal time (UT) in seconds from start.

notification_alert

pub sync fn notification_alert ( title : string,
                                 message : string,
                                 importance : ksp::game::Importance,
                                 duration : float ) -> Unit

Show an alert notification

Parameters

Name

Type

Optional

Description

title

string

message

string

importance

ksp::game::Importance

x

duration

float

x

notification_passive

pub sync fn notification_passive ( message : string,
                                   duration : float ) -> Unit

Show a passive notification

Parameters

Name

Type

Optional

Description

message

string

duration

float

x

sleep

pub fn sleep ( seconds : float ) -> Unit

Stop execution of given number of seconds (factions of a seconds are supported as well).

Parameters

Name

Type

Optional

Description

seconds

float

wait_until

pub fn wait_until ( predicate : sync fn() -> bool ) -> Unit

Stop execution until a given condition is met.

Parameters

Name

Type

Optional

Description

predicate

sync fn() -> bool

wait_while

pub fn wait_while ( predicate : sync fn() -> bool ) -> Unit

Stop execution as long as a given condition is met.

Parameters

Name

Type

Optional

Description

predicate

sync fn() -> bool

yield

pub fn yield ( ) -> Unit

Yield execution to allow Unity to do some other stuff inbetween.