Skip to main content

System

Description:

  Provides access to information about the user's system.

getOS

Type: Function.

Description:

  Gets the current operating system. In general, LÖVE abstracts away the need to know the current operating system, but there are a few cases where it can be useful (especially in combination with os.execute.) Overload details:

  1. In LÖVE version 0.8.0, the '''love._os''' string contains the current operating system.

Signature:

getOS: function(): string

Returns:

Return TypeDescription
stringThe current operating system. 'OS X', 'Windows', 'Linux', 'Android' or 'iOS'.

getProcessorCount

Type: Function.

Description:

  Gets the amount of logical processor in the system. Overload details:

  1. The number includes the threads reported if technologies such as Intel's Hyper-threading are enabled. For example, on a 4-core CPU with Hyper-threading, this function will return 8.

Signature:

getProcessorCount: function(): integer

Returns:

Return TypeDescription
integerAmount of logical processors.

setClipboardText

Type: Function.

Description:

  Puts text in the clipboard.

Signature:

setClipboardText: function(text: string)

Parameters:

ParameterTypeDescription
textstringThe new text to hold in the system's clipboard.

getClipboardText

Type: Function.

Description:

  Gets text from the clipboard.

Signature:

getClipboardText: function(): string

Returns:

Return TypeDescription
stringThe text currently held in the system's clipboard.

getPowerInfo

Type: Function.

Description:

  Gets information about the system's power supply.

Signature:

getPowerInfo: function(): string, integer | nil, integer | nil

Returns:

Return TypeDescription
stringThe basic state of the power supply.
integer or nilPercentage of battery life left, between 0 and 100. nil if the value can't be determined or there's no battery.
integer or nilSeconds of battery life left. nil if the value can't be determined or there's no battery.

openURL

Type: Function.

Description:

  Opens a URL with the user's web or file browser. Overload details:

  1. Passing file:// scheme in Android 7.0 (Nougat) and later always result in failure. Prior to 11.2, this will crash LÖVE instead of returning false.

Signature:

openURL: function(url: string): boolean

Parameters:

ParameterTypeDescription
urlstringThe URL to open. Must be formatted as a proper URL.

Returns:

Return TypeDescription
booleanWhether the URL was opened successfully.

vibrate

Type: Function.

Description:

  Causes the device to vibrate, if possible. Currently this will only work on Android and iOS devices that have a built-in vibration motor.

Signature:

vibrate: function(seconds?: number)

Parameters:

ParameterTypeDescription
secondsnumberThe duration to vibrate for. If called on an iOS device, it will always vibrate for 0.5 seconds due to limitations in the iOS system APIs. (Default: 0.5.)

hasBackgroundMusic

Type: Function.

Description:

  Gets whether another application on the system is playing music in the background. Currently this is implemented on iOS and Android, and will always return false on other operating systems. The t.audio.mixwithsystem flag in love.conf can be used to configure whether background audio / music from other apps should play while LÖVE is open.

Signature:

hasBackgroundMusic: function(): boolean

Returns:

Return TypeDescription
booleanTrue if the user is playing music in the background via another app, false otherwise.