dotfiles from arch

This commit is contained in:
2025-09-28 11:39:12 +02:00
parent 75885729cd
commit d1c6923bbb
1358 changed files with 575835 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
{
"name" : "LÖVR",
"words" : ["lovr%.%w+"],
"settings" : {
"Lua.runtime.version" : "LuaJIT"
}
}

View File

@@ -0,0 +1,230 @@
---@meta
---
---The `lovr.conf` callback lets you configure default settings for LÖVR.
---
---It is called once right before the game starts.
---
---Make sure you put `lovr.conf` in a file called `conf.lua`, a special file that's loaded before the rest of the framework initializes.
---
---
---### NOTE:
---Disabling unused modules can improve startup time.
---
---`t.window` can be set to nil to avoid creating the window.
---
---The window can later be opened manually using `lovr.system.openWindow`.
---
---Enabling the `t.graphics.debug` flag will add additional error checks and will send messages from the GPU driver to the `lovr.log` callback.
---
---This will decrease performance but can help provide information on performance problems or other bugs.
---
---The `headset.offset` field is a vertical offset applied to the scene for headsets that do not center their tracking origin on the floor.
---
---This can be thought of as a "default user height". Setting this offset makes it easier to design experiences that work in both seated and standing VR configurations.
---
---@type fun(t: table)
lovr.conf = nil
---
---This callback is called every frame, and receives a `Pass` object as an argument which can be used to render graphics to the display.
---
---If a VR headset is connected, this function renders to the headset display, otherwise it will render to the desktop window.
---
---
---### NOTE:
---To render to the desktop window when a VR headset is connected, use the `lovr.mirror` callback.
---
---The display is cleared to the global background color before this callback is called, which can be changed using `lovr.graphics.setBackgroundColor`.
---
---Since the `lovr.graphics.submit` function always returns true, the following idiom can be used to submit graphics work manually and override the default submission:
---
--- function lovr.draw(pass)
--- local passes = {}
---
--- -- ... record multiple passes and add to passes table
---
--- return lovr.graphics.submit(passes)
--- end
---
---@type fun(pass: lovr.Pass):boolean
lovr.draw = nil
---
---The `lovr.errhand` callback is run whenever an error occurs.
---
---It receives a parameter containing the error message.
---
---It should return a handler function that will run in a loop to render the error screen.
---
---This handler function is of the same type as the one returned by `lovr.run` and has the same requirements (such as pumping events).
---
---If an error occurs while this handler is running, the program will terminate immediately -- `lovr.errhand` will not be given a second chance.
---
---Errors which occur in the error handler or in the handler it returns may not be cleanly reported, so be careful.
---
---A default error handler is supplied that renders the error message as text to the headset and to the window.
---
---@type fun(message: string):function
lovr.errhand = nil
---
---The `lovr.focus` callback is called whenever the application acquires or loses focus (for example, when opening or closing the Steam dashboard).
---
---The callback receives a single argument, focused, which is a boolean indicating whether or not the application is now focused.
---
---It may make sense to pause the game or reduce visual fidelity when the application loses focus.
---
---@type fun(focused: boolean)
lovr.focus = nil
---
---This callback is called when a key is pressed.
---
---@type fun(key: lovr.KeyCode, scancode: number, repeating: boolean)
lovr.keypressed = nil
---
---This callback is called when a key is released.
---
---@type fun(key: lovr.KeyCode, scancode: number)
lovr.keyreleased = nil
---
---This callback is called once when the app starts.
---
---It should be used to perform initial setup work, like loading resources and initializing classes and variables.
---
---
---### NOTE:
---If the project was loaded from a restart using `lovr.event.restart`, the return value from the previously-run `lovr.restart` callback will be made available to this callback as the `restart` key in the `arg` table.
---
---The `arg` table follows the [Lua standard](https://en.wikibooks.org/wiki/Lua_Programming/command_line_parameter).
---
---The arguments passed in from the shell are put into a global table named `arg` and passed to `lovr.load`, but with indices offset such that the "script" (the project path) is at index 0.
---
---So all arguments (if any) intended for the project are at successive indices starting with 1, and the executable and its "internal" arguments are in normal order but stored in negative indices.
---
---@type fun(arg: table)
lovr.load = nil
---
---This callback is called when a message is logged.
---
---The default implementation of this callback prints the message to the console using `print`, but it's possible to override this callback to render messages in VR, write them to a file, filter messages, and more.
---
---The message can have a "tag" that is a short string representing the sender, and a "level" indicating how severe the message is.
---
---The `t.graphics.debug` flag in `lovr.conf` can be used to get log messages from the GPU driver (tagged as `GPU`).
---
---It is also possible to emit customlog messages using `lovr.event.push`, or by calling the callback.
---
---@type fun(message: string, level: string, tag: string)
lovr.log = nil
---
---This callback is called every frame after rendering to the headset and is usually used to render a mirror of the headset display onto the desktop window.
---
---It can be overridden for custom mirroring behavior.
---
---For example, a stereo view could be drawn instead of a single eye or a 2D HUD could be rendered.
---
---@type fun(pass: lovr.Pass):boolean
lovr.mirror = nil
---
---This callback contains a permission response previously requested with `lovr.system.requestPermission`.
---
---The callback contains information on whether permission was granted or denied.
---
---@type fun(permission: lovr.Permission, granted: boolean)
lovr.permission = nil
---
---This callback is called right before the application is about to quit.
---
---Use it to perform any necessary cleanup work.
---
---A truthy value can be returned from this callback to abort quitting.
---
---@type fun():boolean
lovr.quit = nil
---
---This callback is called when the desktop window is resized.
---
---@type fun(width: number, height: number)
lovr.resize = nil
---
---This callback is called when a restart from `lovr.event.restart` is happening.
---
---A value can be returned to send it to the next LÖVR instance, available as the `restart` key in the argument table passed to `lovr.load`.
---
---Object instances can not be used as the restart value, since they are destroyed as part of the cleanup process.
---
---
---### NOTE:
---Only nil, booleans, numbers, and strings are supported types for the return value.
---
---@type fun():any
lovr.restart = nil
---
---This callback is the main entry point for a LÖVR program.
---
---It calls `lovr.load` and returns a function that will be called every frame.
---
---
---### NOTE:
---The main loop function can return one of the following values:
---
---- Returning `nil` will keep the main loop running.
---- Returning the string 'restart' plus an optional value will restart LÖVR.
---
---The value can be
--- accessed in the `restart` key of the `arg` global.
---- Returning a number will exit LÖVR using the number as the exit code (0 means success).
---
---Care should be taken when overriding this callback.
---
---For example, if the main loop does not call `lovr.event.pump` then the OS will think LÖVR is unresponsive, and if the quit event is not handled then closing the window won't work.
---
---@type fun():function
lovr.run = nil
---
---This callback is called when text has been entered.
---
---For example, when `shift + 1` is pressed on an American keyboard, `lovr.textinput` will be called with `!`.
---
---
---### NOTE:
---Some characters in UTF-8 unicode take multiple bytes to encode.
---
---Due to the way Lua works, the length of these strings will be bigger than 1 even though they are just a single character. `Pass:text` is compatible with UTF-8 but doing other string processing on these strings may require a library.
---
---Lua 5.3+ has support for working with UTF-8 strings.
---
---@type fun(text: string, code: number)
lovr.textinput = nil
---
---The `lovr.threaderror` callback is called whenever an error occurs in a Thread.
---
---It receives the Thread object where the error occurred and an error message.
---
---The default implementation of this callback will call `lovr.errhand` with the error.
---
---@type fun(thread: lovr.Thread, message: string)
lovr.threaderror = nil
---
---The `lovr.update` callback should be used to update your game's logic.
---
---It receives a single parameter, `dt`, which represents the amount of elapsed time between frames.
---
---You can use this value to scale timers, physics, and animations in your game so they play at a smooth, consistent speed.
---
---@type fun(dt: number)
lovr.update = nil

View File

@@ -0,0 +1,42 @@
---@meta
---
---`lovr` is the single global table that is exposed to every LÖVR app. It contains a set of **modules** and a set of **callbacks**.
---
---@class lovr
lovr = {}
---
---Get the current major, minor, and patch version of LÖVR.
---
---@return number major # The major version.
---@return number minor # The minor version.
---@return number patch # The patch number.
function lovr.getVersion() end
---
---The superclass of all LÖVR objects.
---
---In addition to the methods here, all objects have a `__tostring` metamethod that returns the name of the object's type.
---
---So `tostring(object) == 'Blob'` will check if a LÖVR object is a Blob.
---
---
---### NOTE:
---Note that the functions here don't apply to any vector objects, see `Vectors`.
---
---@class lovr.Object
local Object = {}
---
---Immediately destroys Lua's reference to the object it's called on.
---
---After calling this function on an object, it is an error to do anything with the object from Lua (call methods on it, pass it to other functions, etc.).
---
---If nothing else is using the object, it will be destroyed immediately, which can be used to destroy something earlier than it would normally be garbage collected in order to reduce memory.
---
---
---### NOTE:
---The object may not be destroyed immediately if something else is referring to it (e.g. it is pushed to a Channel or exists in the payload of a pending event).
---
function Object:release() end

View File

@@ -0,0 +1,844 @@
---@meta
---
---The `lovr.audio` module is responsible for playing sound effects and music.
---
---To play a sound, create a `Source` object and call `Source:play` on it.
---
---Currently ogg, wav, and mp3 audio formats are supported.
---
---@class lovr.audio
lovr.audio = {}
---
---Returns the global air absorption coefficients for the medium.
---
---This affects Sources that have the `absorption` effect enabled, causing audio volume to drop off with distance as it is absorbed by the medium it's traveling through (air, water, etc.).
---
---The difference between absorption and the attenuation effect is that absorption is more subtle and is frequency-dependent, so higher-frequency bands can get absorbed more quickly than lower ones. This can be used to apply "underwater" effects and stuff.
---
---
---### NOTE:
---Absorption is currently only supported by the phonon spatializer.
---
---The frequency bands correspond to `400Hz`, `2.5KHz`, and `15KHz`.
---
---The default coefficients are `.0002`, `.0017`, and `.0182` for low, mid, and high.
---
---@return number low # The absorption coefficient for the low frequency band.
---@return number mid # The absorption coefficient for the mid frequency band.
---@return number high # The absorption coefficient for the high frequency band.
function lovr.audio.getAbsorption() end
---
---Returns a list of playback or capture devices.
---
---Each device has an `id`, `name`, and a `default` flag indicating whether it's the default device.
---
---To use a specific device id for playback or capture, pass it to `lovr.audio.setDevice`.
---
---@param type? lovr.AudioType # The type of devices to query (playback or capture).
---@return {["[].id"]: userdata, ["[].name"]: string, ["[].default"]: boolean} devices # The list of devices.
function lovr.audio.getDevices(type) end
---
---Returns the orientation of the virtual audio listener in angle/axis representation.
---
---@return number angle # The number of radians the listener is rotated around its axis of rotation.
---@return number ax # The x component of the axis of rotation.
---@return number ay # The y component of the axis of rotation.
---@return number az # The z component of the axis of rotation.
function lovr.audio.getOrientation() end
---
---Returns the position and orientation of the virtual audio listener.
---
---@return number x # The x position of the listener, in meters.
---@return number y # The y position of the listener, in meters.
---@return number z # The z position of the listener, in meters.
---@return number angle # The number of radians the listener is rotated around its axis of rotation.
---@return number ax # The x component of the axis of rotation.
---@return number ay # The y component of the axis of rotation.
---@return number az # The z component of the axis of rotation.
function lovr.audio.getPose() end
---
---Returns the position of the virtual audio listener, in meters.
---
---@return number x # The x position of the listener.
---@return number y # The y position of the listener.
---@return number z # The z position of the listener.
function lovr.audio.getPosition() end
---
---Returns the sample rate used by the playback device.
---
---This can be changed using `lovr.conf`.
---
---@return number rate # The sample rate of the playback device, in Hz.
function lovr.audio.getSampleRate() end
---
---Returns the name of the active spatializer (`simple`, `oculus`, or `phonon`).
---
---The `t.audio.spatializer` setting in `lovr.conf` can be used to express a preference for a particular spatializer.
---
---If it's `nil`, all spatializers will be tried in the following order: `phonon`, `oculus`, `simple`.
---
---
---### NOTE:
---Using a feature or effect that is not supported by the current spatializer will not error, it just won't do anything.
---
---<table>
--- <thead>
--- <tr>
--- <td>Feature</td>
--- <td>simple</td>
--- <td>phonon</td>
--- <td>oculus</td>
--- </tr>
--- </thead>
--- <tbody>
--- <tr>
--- <td>Effect: Spatialization</td>
--- <td>x</td>
--- <td>x</td>
--- <td>x</td>
--- </tr>
--- <tr>
--- <td>Effect: Attenuation</td>
--- <td>x</td>
--- <td>x</td>
--- <td>x</td>
--- </tr>
--- <tr>
--- <td>Effect: Absorption</td>
--- <td></td>
--- <td>x</td>
--- <td></td>
--- </tr>
--- <tr>
--- <td>Effect: Occlusion</td>
--- <td></td>
--- <td>x</td>
--- <td></td>
--- </tr>
--- <tr>
--- <td>Effect: Transmission</td>
--- <td></td>
--- <td>x</td>
--- <td></td>
--- </tr>
--- <tr>
--- <td>Effect: Reverb</td>
--- <td></td>
--- <td>x</td>
--- <td></td>
--- </tr>
--- <tr>
--- <td>lovr.audio.setGeometry</td>
--- <td></td>
--- <td>x</td>
--- <td></td>
--- </tr>
--- <tr>
--- <td>Source:setDirectivity</td>
--- <td>x</td>
--- <td>x</td>
--- <td></td>
--- </tr>
--- <tr>
--- <td>Source:setRadius</td>
--- <td></td>
--- <td>x</td>
--- <td></td>
--- </tr>
--- </tbody> </table>
---
---@return string spatializer # The name of the active spatializer.
function lovr.audio.getSpatializer() end
---
---Returns the master volume.
---
---All audio sent to the playback device has its volume multiplied by this factor.
---
---
---### NOTE:
---The default volume is 1.0 (0 dB).
---
---@param units? lovr.VolumeUnit # The units to return (linear or db).
---@return number volume # The master volume.
function lovr.audio.getVolume(units) end
---
---Returns whether an audio device is started.
---
---@param type? lovr.AudioType # The type of device to check.
---@return boolean started # Whether the device is active.
function lovr.audio.isStarted(type) end
---
---Creates a new Source from an ogg, wav, or mp3 file.
---
---@overload fun(blob: lovr.Blob, options?: table):lovr.Source
---@overload fun(sound: lovr.Sound, options?: table):lovr.Source
---@param filename string # The filename of the sound to load.
---@param options? {decode: boolean, pitchable: boolean, spatial: boolean, effects: table} # Optional options.
---@return lovr.Source source # The new Source.
function lovr.audio.newSource(filename, options) end
---
---Sets the global air absorption coefficients for the medium.
---
---This affects Sources that have the `absorption` effect enabled, causing audio volume to drop off with distance as it is absorbed by the medium it's traveling through (air, water, etc.).
---
---The difference between absorption and the attenuation effect is that absorption is more subtle and is frequency-dependent, so higher-frequency bands can get absorbed more quickly than lower ones.
---
---This can be used to apply "underwater" effects and stuff.
---
---
---### NOTE:
---Absorption is currently only supported by the phonon spatializer.
---
---The frequency bands correspond to `400Hz`, `2.5KHz`, and `15KHz`.
---
---The default coefficients are `.0002`, `.0017`, and `.0182` for low, mid, and high.
---
---@param low number # The absorption coefficient for the low frequency band.
---@param mid number # The absorption coefficient for the mid frequency band.
---@param high number # The absorption coefficient for the high frequency band.
function lovr.audio.setAbsorption(low, mid, high) end
---
---Switches either the playback or capture device to a new one.
---
---If a device for the given type is already active, it will be stopped and destroyed.
---
---The new device will not be started automatically, use `lovr.audio.start` to start it.
---
---A device id (previously retrieved using `lovr.audio.getDevices`) can be given to use a specific audio device, or `nil` can be used for the id to use the default audio device.
---
---A sink can be also be provided when changing the device.
---
---A sink is an audio stream (`Sound` object with a `stream` type) that will receive all audio samples played (for playback) or all audio samples captured (for capture).
---
---When an audio device with a sink is started, be sure to periodically call `Sound:read` on the sink to read audio samples from it, otherwise it will overflow and discard old data.
---
---The sink can have any format, data will be converted as needed. Using a sink for the playback device will reduce performance, but this isn't the case for capture devices.
---
---Audio devices can be started in `shared` or `exclusive` mode.
---
---Exclusive devices may have lower latency than shared devices, but there's a higher chance that requesting exclusive access to an audio device will fail (either because it isn't supported or allowed).
---
---One strategy is to first try the device in exclusive mode, switching to shared if it doesn't work.
---
---@param type? lovr.AudioType # The device to switch.
---@param id? userdata # The id of the device to use, or `nil` to use the default device.
---@param sink? lovr.Sound # An optional audio stream to use as a sink for the device.
---@param mode? lovr.AudioShareMode # The sharing mode for the device.
---@return boolean success # Whether creating the audio device succeeded.
function lovr.audio.setDevice(type, id, sink, mode) end
---
---Sets a mesh of triangles to use for modeling audio effects, using a table of vertices or a Model.
---
---When the appropriate effects are enabled, audio from `Source` objects will correctly be occluded by walls and bounce around to create realistic reverb.
---
---An optional `AudioMaterial` may be provided to specify the acoustic properties of the geometry.
---
---
---### NOTE:
---This is currently only supported/used by the `phonon` spatializer.
---
---The `Effect`s that use geometry are:
---
---- `occlusion`
---- `reverb`
---- `transmission`
---
---If an existing geometry has been set, this function will replace it.
---
---The triangles must use counterclockwise winding.
---
---@overload fun(model: lovr.Model, material?: lovr.AudioMaterial):boolean
---@param vertices table # A flat table of vertices. Each vertex is 3 numbers representing its x, y, and z position. The units used for audio coordinates are up to you, but meters are recommended.
---@param indices table # A list of indices, indicating how the vertices are connected into triangles. Indices are 1-indexed and are 32 bits (they can be bigger than 65535).
---@param material? lovr.AudioMaterial # The acoustic material to use.
---@return boolean success # Whether audio geometry is supported by the current spatializer and the geometry was loaded successfully.
function lovr.audio.setGeometry(vertices, indices, material) end
---
---Sets the orientation of the virtual audio listener in angle/axis representation.
---
---@param angle number # The number of radians the listener should be rotated around its rotation axis.
---@param ax number # The x component of the axis of rotation.
---@param ay number # The y component of the axis of rotation.
---@param az number # The z component of the axis of rotation.
function lovr.audio.setOrientation(angle, ax, ay, az) end
---
---Sets the position and orientation of the virtual audio listener.
---
---@param x number # The x position of the listener, in meters.
---@param y number # The y position of the listener, in meters.
---@param z number # The z position of the listener, in meters.
---@param angle number # The number of radians the listener is rotated around its axis of rotation.
---@param ax number # The x component of the axis of rotation.
---@param ay number # The y component of the axis of rotation.
---@param az number # The z component of the axis of rotation.
function lovr.audio.setPose(x, y, z, angle, ax, ay, az) end
---
---Sets the position of the virtual audio listener, in meters.
---
---@param x number # The x position of the listener.
---@param y number # The y position of the listener.
---@param z number # The z position of the listener.
function lovr.audio.setPosition(x, y, z) end
---
---Sets the master volume.
---
---All audio sent to the playback device has its volume multiplied by this factor.
---
---
---### NOTE:
---The volume will be clamped to a 0-1 range (0 dB).
---
---@param volume number # The master volume.
---@param units? lovr.VolumeUnit # The units of the value.
function lovr.audio.setVolume(volume, units) end
---
---Starts the active playback or capture device.
---
---By default the playback device is initialized and started, but this can be controlled using the `t.audio.start` flag in `lovr.conf`.
---
---
---### NOTE:
---Starting an audio device may fail if:
---
---- The device is already started
---- No device was initialized with `lovr.audio.setDevice`
---- Lack of `audiocapture` permission on Android (see `lovr.system.requestPermission`)
---- Some other problem accessing the audio device
---
---@param type? lovr.AudioType # The type of device to start.
---@return boolean started # Whether the device was successfully started.
function lovr.audio.start(type) end
---
---Stops the active playback or capture device.
---
---This may fail if:
---
---- The device is not started
---- No device was initialized with `lovr.audio.setDevice`
---
---
---### NOTE:
---Switching devices with `lovr.audio.setDevice` will stop the existing one.
---
---@param type? lovr.AudioType # The type of device to stop.
---@return boolean stopped # Whether the device was successfully stopped.
function lovr.audio.stop(type) end
---
---A Source is an object representing a single sound.
---
---Currently ogg, wav, and mp3 formats are supported.
---
---When a Source is playing, it will send audio to the speakers.
---
---Sources do not play automatically when they are created.
---
---Instead, the `play`, `pause`, and `stop` functions can be used to control when they should play.
---
---`Source:seek` and `Source:tell` can be used to control the playback position of the Source.
---
---A Source can be set to loop when it reaches the end using `Source:setLooping`.
---
---@class lovr.Source
local Source = {}
---
---Creates a copy of the Source, referencing the same `Sound` object and inheriting all of the settings of this Source.
---
---However, it will be created in the stopped state and will be rewound to the beginning.
---
---
---### NOTE:
---This is a good way to create multiple Sources that play the same sound, since the audio data won't be loaded multiple times and can just be reused.
---
---You can also create multiple `Source` objects and pass in the same `Sound` object for each one, which will have the same effect.
---
---@return lovr.Source source # A genetically identical copy of the Source.
function Source:clone() end
---
---Returns the directivity settings for the Source.
---
---The directivity is controlled by two parameters: the weight and the power.
---
---The weight is a number between 0 and 1 controlling the general "shape" of the sound emitted. 0.0 results in a completely omnidirectional sound that can be heard from all directions.
---
---1.0 results in a full dipole shape that can be heard only from the front and back.
---
---0.5 results in a cardioid shape that can only be heard from one direction.
---
---Numbers in between will smoothly transition between these.
---
---The power is a number that controls how "focused" or sharp the shape is.
---
---Lower power values can be heard from a wider set of angles.
---
---It is an exponent, so it can get arbitrarily large.
---
---Note that a power of zero will still result in an omnidirectional source, regardless of the weight.
---
---@return number weight # The dipole weight. 0.0 is omnidirectional, 1.0 is a dipole, 0.5 is cardioid.
---@return number power # The dipole power, controlling how focused the directivity shape is.
function Source:getDirectivity() end
---
---Returns the duration of the Source.
---
---@param unit? lovr.TimeUnit # The unit to return.
---@return number duration # The duration of the Source.
function Source:getDuration(unit) end
---
---Returns the orientation of the Source, in angle/axis representation.
---
---@return number angle # The number of radians the Source is rotated around its axis of rotation.
---@return number ax # The x component of the axis of rotation.
---@return number ay # The y component of the axis of rotation.
---@return number az # The z component of the axis of rotation.
function Source:getOrientation() end
---
---Returns the pitch of the Source.
---
---
---### NOTE:
---The default pitch is 1.
---
---Every doubling/halving of the pitch will raise/lower the pitch by one octave.
---
---Changing the pitch also changes the playback speed.
---
---@return number pitch # The pitch.
function Source:getPitch() end
---
---Returns the position and orientation of the Source.
---
---@return number x # The x position of the Source, in meters.
---@return number y # The y position of the Source, in meters.
---@return number z # The z position of the Source, in meters.
---@return number angle # The number of radians the Source is rotated around its axis of rotation.
---@return number ax # The x component of the axis of rotation.
---@return number ay # The y component of the axis of rotation.
---@return number az # The z component of the axis of rotation.
function Source:getPose() end
---
---Returns the position of the Source, in meters.
---
---Setting the position will cause the Source to be distorted and attenuated based on its position relative to the listener.
---
---@return number x # The x coordinate.
---@return number y # The y coordinate.
---@return number z # The z coordinate.
function Source:getPosition() end
---
---Returns the radius of the Source, in meters.
---
---This does not control falloff or attenuation.
---
---It is only used for smoothing out occlusion.
---
---If a Source doesn't have a radius, then when it becomes occluded by a wall its volume will instantly drop.
---
---Giving the Source a radius that approximates its emitter's size will result in a smooth transition between audible and occluded, improving realism.
---
---@return number radius # The radius of the Source, in meters.
function Source:getRadius() end
---
---Returns the `Sound` object backing the Source.
---
---Multiple Sources can share one Sound, allowing its data to only be loaded once.
---
---An easy way to do this sharing is by using `Source:clone`.
---
---@return lovr.Sound sound # The Sound object.
function Source:getSound() end
---
---Returns the current volume factor for the Source.
---
---@param units? lovr.VolumeUnit # The units to return (linear or db).
---@return number volume # The volume of the Source.
function Source:getVolume(units) end
---
---Returns whether a given `Effect` is enabled for the Source.
---
---
---### NOTE:
---The active spatializer will determine which effects are supported.
---
---If an unsupported effect is enabled on a Source, no error will be reported.
---
---Instead, it will be silently ignored.
---
---See `lovr.audio.getSpatializer` for a table showing the effects supported by each spatializer.
---
---Calling this function on a non-spatial Source will always return false.
---
---@param effect lovr.Effect # The effect.
---@return boolean enabled # Whether the effect is enabled.
function Source:isEffectEnabled(effect) end
---
---Returns whether or not the Source will loop when it finishes.
---
---@return boolean looping # Whether or not the Source is looping.
function Source:isLooping() end
---
---Returns whether or not the Source is playing.
---
---@return boolean playing # Whether the Source is playing.
function Source:isPlaying() end
---
---Returns whether the Source was created with the `spatial` flag.
---
---Non-spatial sources are routed directly to the speakers and can not use effects.
---
---@return boolean spatial # Whether the source is spatial.
function Source:isSpatial() end
---
---Pauses the source.
---
---It can be resumed with `Source:resume` or `Source:play`. If a paused source is rewound, it will remain paused.
---
function Source:pause() end
---
---Plays the Source.
---
---This doesn't do anything if the Source is already playing.
---
---
---### NOTE:
---There is a maximum of 64 Sources that can be playing at once.
---
---If 64 Sources are already playing, this function will return `false`.
---
---@return boolean success # Whether the Source successfully started playing.
function Source:play() end
---
---Seeks the Source to the specified position.
---
---
---### NOTE:
---Seeking a Source backed by a stream `Sound` has no meaningful effect.
---
---@param position number # The position to seek to.
---@param unit? lovr.TimeUnit # The units for the seek position.
function Source:seek(position, unit) end
---
---Sets the directivity settings for the Source.
---
---The directivity is controlled by two parameters: the weight and the power.
---
---The weight is a number between 0 and 1 controlling the general "shape" of the sound emitted. 0.0 results in a completely omnidirectional sound that can be heard from all directions.
---
---1.0 results in a full dipole shape that can be heard only from the front and back.
---
---0.5 results in a cardioid shape that can only be heard from one direction.
---
---Numbers in between will smoothly transition between these.
---
---The power is a number that controls how "focused" or sharp the shape is.
---
---Lower power values can be heard from a wider set of angles.
---
---It is an exponent, so it can get arbitrarily large.
---
---Note that a power of zero will still result in an omnidirectional source, regardless of the weight.
---
---@param weight number # The dipole weight. 0.0 is omnidirectional, 1.0 is a dipole, 0.5 is cardioid.
---@param power number # The dipole power, controlling how focused the directivity shape is.
function Source:setDirectivity(weight, power) end
---
---Enables or disables an effect on the Source.
---
---
---### NOTE:
---The active spatializer will determine which effects are supported.
---
---If an unsupported effect is enabled on a Source, no error will be reported.
---
---Instead, it will be silently ignored.
---
---See `lovr.audio.getSpatializer` for a table showing the effects supported by each spatializer.
---
---Calling this function on a non-spatial Source will throw an error.
---
---@param effect lovr.Effect # The effect.
---@param enable boolean # Whether the effect should be enabled.
function Source:setEffectEnabled(effect, enable) end
---
---Sets whether or not the Source loops.
---
---
---### NOTE:
---Attempting to loop a Source backed by a stream `Sound` will cause an error.
---
---@param loop boolean # Whether or not the Source will loop.
function Source:setLooping(loop) end
---
---Sets the orientation of the Source in angle/axis representation.
---
---@param angle number # The number of radians the Source should be rotated around its rotation axis.
---@param ax number # The x component of the axis of rotation.
---@param ay number # The y component of the axis of rotation.
---@param az number # The z component of the axis of rotation.
function Source:setOrientation(angle, ax, ay, az) end
---
---Sets the pitch of the Source.
---
---
---### NOTE:
---The default pitch is 1.
---
---Every doubling/halving of the pitch will raise/lower the pitch by one octave.
---
---Changing the pitch also changes the playback speed.
---
---@param pitch number # The new pitch.
function Source:setPitch(pitch) end
---
---Sets the position and orientation of the Source.
---
---@param x number # The x position of the Source, in meters.
---@param y number # The y position of the Source, in meters.
---@param z number # The z position of the Source, in meters.
---@param angle number # The number of radians the Source is rotated around its axis of rotation.
---@param ax number # The x component of the axis of rotation.
---@param ay number # The y component of the axis of rotation.
---@param az number # The z component of the axis of rotation.
function Source:setPose(x, y, z, angle, ax, ay, az) end
---
---Sets the position of the Source, in meters.
---
---Setting the position will cause the Source to be distorted and attenuated based on its position relative to the listener.
---
---Only mono sources can be positioned.
---
---Setting the position of a stereo Source will cause an error.
---
---@param x number # The x coordinate.
---@param y number # The y coordinate.
---@param z number # The z coordinate.
function Source:setPosition(x, y, z) end
---
---Sets the radius of the Source, in meters.
---
---This does not control falloff or attenuation.
---
---It is only used for smoothing out occlusion.
---
---If a Source doesn't have a radius, then when it becomes occluded by a wall its volume will instantly drop.
---
---Giving the Source a radius that approximates its emitter's size will result in a smooth transition between audible and occluded, improving realism.
---
---@param radius number # The new radius of the Source, in meters.
function Source:setRadius(radius) end
---
---Sets the current volume factor for the Source.
---
---
---### NOTE:
---The volume will be clamped to a 0-1 range (0 dB).
---
---@param volume number # The new volume.
---@param units? lovr.VolumeUnit # The units of the value.
function Source:setVolume(volume, units) end
---
---Stops the source, also rewinding it to the beginning.
---
function Source:stop() end
---
---Returns the current playback position of the Source.
---
---
---### NOTE:
---The return value for Sources backed by a stream `Sound` has no meaning.
---
---@param unit? lovr.TimeUnit # The unit to return.
---@return number position # The current playback position.
function Source:tell(unit) end
---
---Different types of audio material presets, for use with `lovr.audio.setGeometry`.
---
---@alias lovr.AudioMaterial
---
---Generic default audio material.
---
---| "generic"
---
---Brick.
---
---| "brick"
---
---Carpet.
---
---| "carpet"
---
---Ceramic.
---
---| "ceramic"
---
---Concrete.
---
---| "concrete"
---
---Glass.
---
---| "glass"
---
---Gravel.
---
---| "gravel"
---
---Metal.
---
---| "metal"
---
---Plaster.
---
---| "plaster"
---
---Rock.
---
---| "rock"
---
---Wood.
---
---| "wood"
---
---Audio devices can be created in shared mode or exclusive mode.
---
---In exclusive mode, the audio device is the only one active on the system, which gives better performance and lower latency. However, exclusive devices aren't always supported and might not be allowed, so there is a higher chance that creating one will fail.
---
---@alias lovr.AudioShareMode
---
---Shared mode.
---
---| "shared"
---
---Exclusive mode.
---
---| "exclusive"
---
---When referencing audio devices, this indicates whether it's the playback or capture device.
---
---@alias lovr.AudioType
---
---The playback device (speakers, headphones).
---
---| "playback"
---
---The capture device (microphone).
---
---| "capture"
---
---Different types of effects that can be applied with `Source:setEffectEnabled`.
---
---
---### NOTE:
---The active spatializer will determine which effects are supported.
---
---If an unsupported effect is enabled on a Source, no error will be reported.
---
---Instead, it will be silently ignored.
---
---See `lovr.audio.getSpatializer` for a table of the supported effects for each spatializer.
---
---@alias lovr.Effect
---
---Models absorption as sound travels through the air, water, etc.
---
---| "absorption"
---
---Decreases audio volume with distance (1 / max(distance, 1)).
---
---| "attenuation"
---
---Causes audio to drop off when the Source is occluded by geometry.
---
---| "occlusion"
---
---Models reverb caused by audio bouncing off of geometry.
---
---| "reverb"
---
---Spatializes the Source using either simple panning or an HRTF.
---
---| "spatialization"
---
---Causes audio to be heard through walls when occluded, based on audio materials.
---
---| "transmission"
---
---When figuring out how long a Source is or seeking to a specific position in the sound file, units can be expressed in terms of seconds or in terms of frames.
---
---A frame is one set of samples for each channel (one sample for mono, two samples for stereo).
---
---@alias lovr.TimeUnit
---
---Seconds.
---
---| "seconds"
---
---Frames.
---
---| "frames"
---
---When accessing the volume of Sources or the audio listener, this can be done in linear units with a 0 to 1 range, or in decibels with a range of -∞ to 0.
---
---@alias lovr.VolumeUnit
---
---Linear volume range.
---
---| "linear"
---
---Decibels.
---
---| "db"

View File

@@ -0,0 +1,430 @@
---@meta
---
---The `lovr.event` module handles events from the operating system.
---
---Due to its low-level nature, it's rare to use `lovr.event` in simple projects.
---
---
---### NOTE:
---You can define your own custom events by adding a function to the `lovr.handlers` table with a key of the name of the event you want to add.
---
---Then, push the event using `lovr.event.push`.
---
---@class lovr.event
lovr.event = {}
---
---Clears the event queue, removing any unprocessed events.
---
function lovr.event.clear() end
---
---This function returns a Lua iterator for all of the unprocessed items in the event queue.
---
---Each event consists of a name as a string, followed by event-specific arguments.
---
---This function is called in the default implementation of `lovr.run`, so it is normally not necessary to poll for events yourself.
---
---@return function iterator # The iterator function, usable in a for loop.
function lovr.event.poll() end
---
---Fills the event queue with unprocessed events from the operating system.
---
---This function should be called often, otherwise the operating system will consider the application unresponsive. This function is called in the default implementation of `lovr.run`.
---
function lovr.event.pump() end
---
---Pushes an event onto the event queue.
---
---It will be processed the next time `lovr.event.poll` is called.
---
---For an event to be processed properly, there needs to be a function in the `lovr.handlers` table with a key that's the same as the event name.
---
---
---### NOTE:
---Only nil, booleans, numbers, strings, and LÖVR objects are supported types for event data.
---
---@param name string # The name of the event.
---@vararg any # The arguments for the event. Currently, up to 4 are supported.
function lovr.event.push(name, ...) end
---
---Pushes an event to quit.
---
---An optional number can be passed to set the exit code for the application.
---
---An exit code of zero indicates normal termination, whereas a nonzero exit code indicates that an error occurred.
---
---
---### NOTE:
---This function is equivalent to calling `lovr.event.push('quit', <args>)`.
---
---The event won't be processed until the next time `lovr.event.poll` is called.
---
---The `lovr.quit` callback will be called when the event is processed, which can be used to do any cleanup work.
---
---The callback can also return `false` to abort the quitting process.
---
---@param code? number # The exit code of the program.
function lovr.event.quit(code) end
---
---Pushes an event to restart the framework.
---
---
---### NOTE:
---The event won't be processed until the next time `lovr.event.poll` is called.
---
---The `lovr.restart` callback can be used to persist a value between restarts.
---
function lovr.event.restart() end
---
---Keys that can be pressed on a keyboard.
---
---Notably, numpad keys are missing right now.
---
---@alias lovr.KeyCode
---
---The A key.
---
---| "a"
---
---The B key.
---
---| "b"
---
---The C key.
---
---| "c"
---
---The D key.
---
---| "d"
---
---The E key.
---
---| "e"
---
---The F key.
---
---| "f"
---
---The G key.
---
---| "g"
---
---The H key.
---
---| "h"
---
---The I key.
---
---| "i"
---
---The J key.
---
---| "j"
---
---The K key.
---
---| "k"
---
---The L key.
---
---| "l"
---
---The M key.
---
---| "m"
---
---The N key.
---
---| "n"
---
---The O key.
---
---| "o"
---
---The P key.
---
---| "p"
---
---The Q key.
---
---| "q"
---
---The R key.
---
---| "r"
---
---The S key.
---
---| "s"
---
---The T key.
---
---| "t"
---
---The U key.
---
---| "u"
---
---The V key.
---
---| "v"
---
---The W key.
---
---| "w"
---
---The X key.
---
---| "x"
---
---The Y key.
---
---| "y"
---
---The Z key.
---
---| "z"
---
---The 0 key.
---
---| "0"
---
---The 1 key.
---
---| "1"
---
---The 2 key.
---
---| "2"
---
---The 3 key.
---
---| "3"
---
---The 4 key.
---
---| "4"
---
---The 5 key.
---
---| "5"
---
---The 6 key.
---
---| "6"
---
---The 7 key.
---
---| "7"
---
---The 8 key.
---
---| "8"
---
---The 9 key.
---
---| "9"
---
---The space bar.
---
---| "space"
---
---The enter key.
---
---| "return"
---
---The tab key.
---
---| "tab"
---
---The escape key.
---
---| "escape"
---
---The backspace key.
---
---| "backspace"
---
---The up arrow key.
---
---| "up"
---
---The down arrow key.
---
---| "down"
---
---The left arrow key.
---
---| "left"
---
---The right arrow key.
---
---| "right"
---
---The home key.
---
---| "home"
---
---The end key.
---
---| "end"
---
---The page up key.
---
---| "pageup"
---
---The page down key.
---
---| "pagedown"
---
---The insert key.
---
---| "insert"
---
---The delete key.
---
---| "delete"
---
---The F1 key.
---
---| "f1"
---
---The F2 key.
---
---| "f2"
---
---The F3 key.
---
---| "f3"
---
---The F4 key.
---
---| "f4"
---
---The F5 key.
---
---| "f5"
---
---The F6 key.
---
---| "f6"
---
---The F7 key.
---
---| "f7"
---
---The F8 key.
---
---| "f8"
---
---The F9 key.
---
---| "f9"
---
---The F10 key.
---
---| "f10"
---
---The F11 key.
---
---| "f11"
---
---The F12 key.
---
---| "f12"
---
---The backtick/backquote/grave accent key.
---
---| "`"
---
---The dash/hyphen/minus key.
---
---| "-"
---
---The equal sign key.
---
---| "="
---
---The left bracket key.
---
---| "["
---
---The right bracket key.
---
---| "]"
---
---The backslash key.
---
---| "\\"
---
---The semicolon key.
---
---| ";"
---
---The single quote key.
---
---| "'"
---
---The comma key.
---
---| ","
---
---The period key.
---
---| "."
---
---The slash key.
---
---| "/"
---
---The left control key.
---
---| "lctrl"
---
---The left shift key.
---
---| "lshift"
---
---The left alt key.
---
---| "lalt"
---
---The left OS key (windows, command, super).
---
---| "lgui"
---
---The right control key.
---
---| "rctrl"
---
---The right shift key.
---
---| "rshift"
---
---The right alt key.
---
---| "ralt"
---
---The right OS key (windows, command, super).
---
---| "rgui"
---
---The caps lock key.
---
---| "capslock"
---
---The scroll lock key.
---
---| "scrolllock"
---
---The numlock key.
---
---| "numlock"

View File

@@ -0,0 +1,317 @@
---@meta
---
---The `lovr.filesystem` module provides access to the filesystem.
---
---
---### NOTE:
---LÖVR programs can only write to a single directory, called the save directory.
---
---The location of the save directory is platform-specific:
---
---<table>
--- <tr>
--- <td>Windows</td>
--- <td><code>C:\Users\&lt;user&gt;\AppData\Roaming\LOVR\&lt;identity&gt;</code></td>
--- </tr>
--- <tr>
--- <td>macOS</td>
--- <td><code>/Users/&lt;user&gt;/Library/Application Support/LOVR/&lt;identity&gt;</code></td>
--- </tr>
--- <tr>
--- <td>Linux</td>
--- <td><code>/home/&lt;user&gt;/.local/share/LOVR/&lt;identity&gt;</code></td>
--- </tr>
--- <tr>
--- <td>Android</td>
--- <td><code>/sdcard/Android/data/&lt;identity&gt;/files</code></td>
--- </tr> </table>
---
---`<identity>` should be a unique identifier for your app.
---
---It can be set either in `lovr.conf` or by using `lovr.filesystem.setIdentity`.
---
---On Android, the identity can not be changed and will always be the package id, like `org.lovr.app`.
---
---All filenames are relative to either the save directory or the directory containing the project source.
---
---Files in the save directory take precedence over files in the project.
---
---@class lovr.filesystem
lovr.filesystem = {}
---
---Appends content to the end of a file.
---
---
---### NOTE:
---If the file does not exist, it is created.
---
---@overload fun(filename: string, blob: lovr.Blob):number
---@param filename string # The file to append to.
---@param content string # A string to write to the end of the file.
---@return number bytes # The number of bytes actually appended to the file.
function lovr.filesystem.append(filename, content) end
---
---Creates a directory in the save directory.
---
---Any parent directories that don't exist will also be created.
---
---@param path string # The directory to create, recursively.
---@return boolean success # Whether the directory was created.
function lovr.filesystem.createDirectory(path) end
---
---Returns the application data directory.
---
---This will be something like:
---
---- `C:\Users\user\AppData\Roaming` on Windows.
---- `/home/user/.config` on Linux.
---- `/Users/user/Library/Application Support` on macOS.
---
---@return string path # The absolute path to the appdata directory.
function lovr.filesystem.getAppdataDirectory() end
---
---Returns a sorted table containing all files and folders in a single directory.
---
---
---### NOTE:
---This function calls `table.sort` to sort the results, so if `table.sort` is not available in the global scope the results are not guaranteed to be sorted.
---
---@param path string # The directory.
---@return lovr.items table # A table with a string for each file and subfolder in the directory.
function lovr.filesystem.getDirectoryItems(path) end
---
---Returns the absolute path of the LÖVR executable.
---
---@return string path # The absolute path of the LÖVR executable, or `nil` if it is unknown.
function lovr.filesystem.getExecutablePath() end
---
---Returns the identity of the game, which is used as the name of the save directory.
---
---The default is `default`.
---
---It can be changed using `t.identity` in `lovr.conf`.
---
---
---### NOTE:
---On Android, this is always the package id (like `org.lovr.app`).
---
---@return string identity # The name of the save directory, or `nil` if it isn't set.
function lovr.filesystem.getIdentity() end
---
---Returns when a file was last modified, since some arbitrary time in the past.
---
---@param path string # The file to check.
---@return number time # The modification time of the file, in seconds, or `nil` if it's unknown.
function lovr.filesystem.getLastModified(path) end
---
---Get the absolute path of the mounted archive containing a path in the virtual filesystem.
---
---This can be used to determine if a file is in the game's source directory or the save directory.
---
---@param path string # The path to check.
---@return string realpath # The absolute path of the mounted archive containing `path`.
function lovr.filesystem.getRealDirectory(path) end
---
---Returns the require path.
---
---The require path is a semicolon-separated list of patterns that LÖVR will use to search for files when they are `require`d.
---
---Any question marks in the pattern will be replaced with the module that is being required.
---
---It is similar to Lua\'s `package.path` variable, but the main difference is that the patterns are relative to the virtual filesystem.
---
---
---### NOTE:
---The default reqiure path is '?.lua;?/init.lua'.
---
---@return string path # The semicolon separated list of search patterns.
function lovr.filesystem.getRequirePath() end
---
---Returns the absolute path to the save directory.
---
---
---### NOTE:
---The save directory takes the following form:
---
--- <appdata>/LOVR/<identity>
---
---Where `<appdata>` is `lovr.filesystem.getAppdataDirectory` and `<identity>` is `lovr.filesystem.getIdentity` and can be customized using `lovr.conf`.
---
---@return string path # The absolute path to the save directory.
function lovr.filesystem.getSaveDirectory() end
---
---Returns the size of a file, in bytes.
---
---
---### NOTE:
---If the file does not exist, an error is thrown.
---
---@param file string # The file.
---@return number size # The size of the file, in bytes.
function lovr.filesystem.getSize(file) end
---
---Get the absolute path of the project's source directory or archive.
---
---@return string path # The absolute path of the project's source, or `nil` if it's unknown.
function lovr.filesystem.getSource() end
---
---Returns the absolute path of the user's home directory.
---
---@return string path # The absolute path of the user's home directory.
function lovr.filesystem.getUserDirectory() end
---
---Returns the absolute path of the working directory.
---
---Usually this is where the executable was started from.
---
---@return string path # The current working directory, or `nil` if it's unknown.
function lovr.filesystem.getWorkingDirectory() end
---
---Check if a path exists and is a directory.
---
---@param path string # The path to check.
---@return boolean isDirectory # Whether or not the path is a directory.
function lovr.filesystem.isDirectory(path) end
---
---Check if a path exists and is a file.
---
---@param path string # The path to check.
---@return boolean isFile # Whether or not the path is a file.
function lovr.filesystem.isFile(path) end
---
---Returns whether the current project source is fused to the executable.
---
---@return boolean fused # Whether or not the project is fused.
function lovr.filesystem.isFused() end
---
---Load a file containing Lua code, returning a Lua chunk that can be run.
---
---
---### NOTE:
---An error is thrown if the file contains syntax errors.
---
---@param filename string # The file to load.
---@return function chunk # The runnable chunk.
function lovr.filesystem.load(filename) end
---
---Mounts a directory or `.zip` archive, adding it to the virtual filesystem.
---
---This allows you to read files from it.
---
---
---### NOTE:
---The `append` option lets you control the priority of the archive's files in the event of naming collisions.
---
---This function is not thread safe.
---
---Mounting or unmounting an archive while other threads call lovr.filesystem functions is not supported.
---
---@param path string # The path to mount.
---@param mountpoint? string # The path in the virtual filesystem to mount to.
---@param append? boolean # Whether the archive will be added to the end or the beginning of the search path.
---@param root? string # A subdirectory inside the archive to use as the root. If `nil`, the actual root of the archive is used.
---@return boolean success # Whether the archive was successfully mounted.
function lovr.filesystem.mount(path, mountpoint, append, root) end
---
---Creates a new Blob that contains the contents of a file.
---
---@param filename string # The file to load.
---@return lovr.Blob blob # The new Blob.
function lovr.filesystem.newBlob(filename) end
---
---Read the contents of a file.
---
---
---### NOTE:
---If the file does not exist or cannot be read, nil is returned.
---
---@param filename string # The name of the file to read.
---@param bytes? number # The number of bytes to read (if -1, all bytes will be read).
---@return string contents # The contents of the file.
---@return number bytes # The number of bytes read from the file.
function lovr.filesystem.read(filename, bytes) end
---
---Remove a file or directory in the save directory.
---
---
---### NOTE:
---A directory can only be removed if it is empty.
---
---To recursively remove a folder, use this function with `lovr.filesystem.getDirectoryItems`.
---
---@param path string # The file or directory to remove.
---@return boolean success # Whether the path was removed.
function lovr.filesystem.remove(path) end
---
---Set the name of the save directory.
---
---@param identity string # The new name of the save directory.
function lovr.filesystem.setIdentity(identity) end
---
---Sets the require path.
---
---The require path is a semicolon-separated list of patterns that LÖVR will use to search for files when they are `require`d.
---
---Any question marks in the pattern will be replaced with the module that is being required.
---
---It is similar to Lua\'s `package.path` variable, but the main difference is that the patterns are relative to the save directory and the project directory.
---
---
---### NOTE:
---The default reqiure path is '?.lua;?/init.lua'.
---
---@param path? string # An optional semicolon separated list of search patterns.
function lovr.filesystem.setRequirePath(path) end
---
---Unmounts a directory or archive previously mounted with `lovr.filesystem.mount`.
---
---
---### NOTE:
---This function is not thread safe.
---
---Mounting or unmounting an archive while other threads call lovr.filesystem functions is not supported.
---
---@param path string # The path to unmount.
---@return boolean success # Whether the archive was unmounted.
function lovr.filesystem.unmount(path) end
---
---Write to a file.
---
---
---### NOTE:
---If the file does not exist, it is created.
---
---If the file already has data in it, it will be replaced with the new content.
---
---@overload fun(filename: string, blob: lovr.Blob):boolean
---@param filename string # The file to write to.
---@param content string # A string to write to the file.
---@return boolean success # Whether the write was successful.
function lovr.filesystem.write(filename, content) end

View File

@@ -0,0 +1,791 @@
---@meta
---
---The `lovr.headset` module is where all the magical VR functionality is.
---
---With it, you can access connected VR hardware and get information about the available space the player has.
---
---Note that all units are reported in meters.
---
---Position `(0, 0, 0)` is on the floor in the center of the play area.
---
---@class lovr.headset
lovr.headset = {}
---
---Animates a device model to match its current input state.
---
---The buttons and joysticks on a controller will move as they're pressed/moved and hand models will move to match skeletal input.
---
---The model should have been created using `lovr.headset.newModel` with the `animated` flag set to `true`.
---
---
---### NOTE:
---Currently this function is only supported for hand models on the Oculus Quest.
---
---It's possible to use models that weren't created with `lovr.headset.newModel` but they need to be set up carefully to have the same structure as the models provided by the headset SDK.
---
---@param device? lovr.Device # The device to use for the animation data.
---@param model lovr.Model # The model to animate.
---@return boolean success # Whether the animation was applied successfully to the Model. If the Model was not compatible or animation data for the device was not available, this will be `false`.
function lovr.headset.animate(device, model) end
---
---Returns the current angular velocity of a device.
---
---@param device? lovr.Device # The device to get the velocity of.
---@return number x # The x component of the angular velocity.
---@return number y # The y component of the angular velocity.
---@return number z # The z component of the angular velocity.
function lovr.headset.getAngularVelocity(device) end
---
---Get the current state of an analog axis on a device.
---
---Some axes are multidimensional, for example a 2D touchpad or thumbstick with x/y axes.
---
---For multidimensional axes, this function will return multiple values, one number for each axis.
---
---In these cases, it can be useful to use the `select` function built in to Lua to select a particular axis component.
---
---
---### NOTE:
---The axis values will be between 0 and 1 for 1D axes, and between -1 and 1 for each component of a multidimensional axis.
---
---When hand tracking is active, pinch strength will be mapped to the `trigger` axis.
---
---@param device lovr.Device # The device.
---@param axis lovr.DeviceAxis # The axis.
function lovr.headset.getAxis(device, axis) end
---
---Returns the depth of the play area, in meters.
---
---
---### NOTE:
---This currently returns 0 on the Quest.
---
---@return number depth # The depth of the play area, in meters.
function lovr.headset.getBoundsDepth() end
---
---Returns the size of the play area, in meters.
---
---
---### NOTE:
---This currently returns 0 on the Quest.
---
---@return number width # The width of the play area, in meters.
---@return number depth # The depth of the play area, in meters.
function lovr.headset.getBoundsDimensions() end
---
---Returns a list of points representing the boundaries of the play area, or `nil` if the current headset driver does not expose this information.
---
---@param t table # A table to fill with the points. If `nil`, a new table will be created.
---@return table points # A flat table of 3D points representing the play area boundaries.
function lovr.headset.getBoundsGeometry(t) end
---
---Returns the width of the play area, in meters.
---
---
---### NOTE:
---This currently returns 0 on the Quest.
---
---@return number width # The width of the play area, in meters.
function lovr.headset.getBoundsWidth() end
---
---Returns the near and far clipping planes used to render to the headset.
---
---Objects closer than the near clipping plane or further than the far clipping plane will be clipped out of view.
---
---
---### NOTE:
---The default near and far clipping planes are 0.01 meters and 0.0 meters.
---
---@return number near # The distance to the near clipping plane, in meters.
---@return number far # The distance to the far clipping plane, in meters, or 0 for an infinite far clipping plane with a reversed Z range.
function lovr.headset.getClipDistance() end
---
---Returns the headset delta time, which is the difference between the current and previous predicted display times.
---
---When the headset is active, this will be the `dt` value passed in to `lovr.update`.
---
---@return number dt # The delta time.
function lovr.headset.getDeltaTime() end
---
---Returns the texture dimensions of the headset display (for one eye), in pixels.
---
---@return number width # The width of the display.
---@return number height # The height of the display.
function lovr.headset.getDisplayDimensions() end
---
---Returns a table with all the refresh rates supported by the headset display, in Hz.
---
---@return table frequencies # A flat table of the refresh rates supported by the headset display, nil if not supported.
function lovr.headset.getDisplayFrequencies() end
---
---Returns the refresh rate of the headset display, in Hz.
---
---@return number frequency # The frequency of the display, or `nil` if I have no idea what it is.
function lovr.headset.getDisplayFrequency() end
---
---Returns the height of the headset display (for one eye), in pixels.
---
---@return number height # The height of the display.
function lovr.headset.getDisplayHeight() end
---
---Returns the width of the headset display (for one eye), in pixels.
---
---@return number width # The width of the display.
function lovr.headset.getDisplayWidth() end
---
---Returns the `HeadsetDriver` that is currently in use, optionally for a specific device.
---
---The order of headset drivers can be changed using `lovr.conf` to prefer or exclude specific VR APIs.
---
---@overload fun(device: lovr.Device):lovr.HeadsetDriver
---@return lovr.HeadsetDriver driver # The driver of the headset in use, e.g. "OpenVR".
function lovr.headset.getDriver() end
---
---Returns a table with all of the currently tracked hand devices.
---
---
---### NOTE:
---The hand paths will *always* be either `hand/left` or `hand/right`.
---
---@return table hands # The currently tracked hand devices.
function lovr.headset.getHands() end
---
---Returns the name of the headset as a string.
---
---The exact string that is returned depends on the hardware and VR SDK that is currently in use.
---
---
---### NOTE:
---The desktop driver name will always be `Simulator`.
---
---@return string name # The name of the headset as a string.
function lovr.headset.getName() end
---
---Returns the current orientation of a device, in angle/axis form.
---
---
---### NOTE:
---If the device isn't tracked, all zeroes will be returned.
---
---@param device? lovr.Device # The device to get the orientation of.
---@return number angle # The amount of rotation around the axis of rotation, in radians.
---@return number ax # The x component of the axis of rotation.
---@return number ay # The y component of the axis of rotation.
---@return number az # The z component of the axis of rotation.
function lovr.headset.getOrientation(device) end
---
---Returns the type of origin used for the tracking volume.
---
---The different types of origins are explained on the `HeadsetOrigin` page.
---
---@return lovr.HeadsetOrigin origin # The type of origin.
function lovr.headset.getOriginType() end
---
---Returns a `Pass` that renders to the headset display.
---
---
---### NOTE:
---The same Pass will be returned until `lovr.headset.submit` is called.
---
---The first time this function is called during a frame, the views of the Pass will be initialized with the headset view poses and view angles.
---
---The pass will be cleared to the background color, which can be changed using `lovr.graphics.setBackgroundColor`.
---
---The pass will have a depth buffer.
---
---If `t.headset.stencil` was set to a truthy value in `lovr.conf`, the depth buffer will use the `d32fs8` format, otherwise `d32f` will be used.
---
---If `t.headset.antialias` was set to a truthy value in `lovr.conf`, the pass will be multisampled.
---
---@return lovr.Pass pass # The pass.
function lovr.headset.getPass() end
---
---Returns the current position and orientation of a device.
---
---
---### NOTE:
---Units are in meters.
---
---If the device isn't tracked, all zeroes will be returned.
---
---@param device? lovr.Device # The device to get the pose of.
---@return number x # The x position.
---@return number y # The y position.
---@return number z # The z position.
---@return number angle # The amount of rotation around the axis of rotation, in radians.
---@return number ax # The x component of the axis of rotation.
---@return number ay # The y component of the axis of rotation.
---@return number az # The z component of the axis of rotation.
function lovr.headset.getPose(device) end
---
---Returns the current position of a device, in meters, relative to the play area.
---
---
---### NOTE:
---If the device isn't tracked, all zeroes will be returned.
---
---@param device? lovr.Device # The device to get the position of.
---@return number x # The x position of the device.
---@return number y # The y position of the device.
---@return number z # The z position of the device.
function lovr.headset.getPosition(device) end
---
---Returns a list of joint transforms tracked by a device.
---
---Currently, only hand devices are able to track joints.
---
---
---### NOTE:
---If the Device does not support tracking joints or the transforms are unavailable, `nil` is returned.
---
---The joint orientation is similar to the graphics coordinate system: -Z is the forwards direction, pointing towards the fingertips.
---
---The +Y direction is "up", pointing out of the back of the hand.
---
---The +X direction is to the right, perpendicular to X and Z.
---
---Hand joints are returned in the following order:
---
---<table>
--- <thead>
--- <tr>
--- <td colspan="2">Joint</td>
--- <td>Index</td>
--- </tr>
--- </thead>
--- <tbody>
--- <tr>
--- <td colspan="2">Palm</td>
--- <td>1</td>
--- </tr>
--- <tr>
--- <td colspan="2">Wrist</td>
--- <td>2</td>
--- </tr>
--- <tr>
--- <td rowspan="4">Thumb</td>
--- <td>Metacarpal</td>
--- <td>3</td>
--- </tr>
--- <tr>
--- <td>Proximal</td>
--- <td>4</td>
--- </tr>
--- <tr>
--- <td>Distal</td>
--- <td>5</td>
--- </tr>
--- <tr>
--- <td>Tip</td>
--- <td>6</td>
--- </tr>
--- <tr>
--- <td rowspan="5">Index</td>
--- <td>Metacarpal</td>
--- <td>7</td>
--- </tr>
--- <tr>
--- <td>Proximal</td>
--- <td>8</td>
--- </tr>
--- <tr>
--- <td>Intermediate</td>
--- <td>9</td>
--- </tr>
--- <tr>
--- <td>Distal</td>
--- <td>10</td>
--- </tr>
--- <tr>
--- <td>Tip</td>
--- <td>11</td>
--- </tr>
--- <tr>
--- <td rowspan="5">Middle</td>
--- <td>Metacarpal</td>
--- <td>12</td>
--- </tr>
--- <tr>
--- <td>Proximal</td>
--- <td>13</td>
--- </tr>
--- <tr>
--- <td>Intermediate</td>
--- <td>14</td>
--- </tr>
--- <tr>
--- <td>Distal</td>
--- <td>15</td>
--- </tr>
--- <tr>
--- <td>Tip</td>
--- <td>16</td>
--- </tr>
--- <tr>
--- <td rowspan="5">Ring</td>
--- <td>Metacarpal</td>
--- <td>17</td>
--- </tr>
--- <tr>
--- <td>Proximal</td>
--- <td>18</td>
--- </tr>
--- <tr>
--- <td>Intermediate</td>
--- <td>19</td>
--- </tr>
--- <tr>
--- <td>Distal</td>
--- <td>20</td>
--- </tr>
--- <tr>
--- <td>Tip</td>
--- <td>21</td>
--- </tr>
--- <tr>
--- <td rowspan="5">Pinky</td>
--- <td>Metacarpal</td>
--- <td>22</td>
--- </tr>
--- <tr>
--- <td>Proximal</td>
--- <td>23</td>
--- </tr>
--- <tr>
--- <td>Intermediate</td>
--- <td>24</td>
--- </tr>
--- <tr>
--- <td>Distal</td>
--- <td>25</td>
--- </tr>
--- <tr>
--- <td>Tip</td>
--- <td>26</td>
--- </tr>
--- </tbody> </table>
---
---@overload fun(device: lovr.Device, t: table):table
---@param device lovr.Device # The Device to query.
---@return table transforms # A list of joint transforms for the device. Each transform is a table with 3 numbers for the position of the joint, 1 number for the joint radius (in meters), and 4 numbers for the angle/axis orientation of the joint.
function lovr.headset.getSkeleton(device) end
---
---Returns a Texture that will be submitted to the headset display.
---
---This will be the render target used in the headset's render pass.
---
---The texture is not guaranteed to be the same every frame, and must be called every frame to get the current texture.
---
---
---### NOTE:
---This function may return `nil` if the headset is not being rendered to this frame.
---
---@return lovr.Texture texture # The headset texture.
function lovr.headset.getTexture() end
---
---Returns the estimated time in the future at which the light from the pixels of the current frame will hit the eyes of the user.
---
---This can be used as a replacement for `lovr.timer.getTime` for timestamps that are used for rendering to get a smoother result that is synchronized with the display of the headset.
---
---
---### NOTE:
---This has a different epoch than `lovr.timer.getTime`, so it is not guaranteed to be close to that value.
---
---@return number time # The predicted display time, in seconds.
function lovr.headset.getTime() end
---
---Returns the current linear velocity of a device, in meters per second.
---
---@param device? lovr.Device # The device to get the velocity of.
---@return number vx # The x component of the linear velocity.
---@return number vy # The y component of the linear velocity.
---@return number vz # The z component of the linear velocity.
function lovr.headset.getVelocity(device) end
---
---Returns the view angles of one of the headset views.
---
---These can be used with `Mat4:fov` to create a projection matrix.
---
---If tracking data is unavailable for the view or the index is invalid, `nil` is returned.
---
---@param view number # The view index.
---@return number left # The left view angle, in radians.
---@return number right # The right view angle, in radians.
---@return number top # The top view angle, in radians.
---@return number bottom # The bottom view angle, in radians.
function lovr.headset.getViewAngles(view) end
---
---Returns the number of views used for rendering.
---
---Each view consists of a pose in space and a set of angle values that determine the field of view.
---
---This is usually 2 for stereo rendering configurations, but it can also be different.
---
---For example, one way of doing foveated rendering uses 2 views for each eye -- one low quality view with a wider field of view, and a high quality view with a narrower field of view.
---
---@return number count # The number of views.
function lovr.headset.getViewCount() end
---
---Returns the pose of one of the headset views.
---
---This info can be used to create view matrices or do other eye-dependent calculations.
---
---If tracking data is unavailable for the view or the index is invalid, `nil` is returned.
---
---@param view number # The view index.
---@return number x # The x coordinate of the view position, in meters.
---@return number y # The y coordinate of the view position, in meters.
---@return number z # The z coordinate of the view position, in meters.
---@return number angle # The amount of rotation around the rotation axis, in radians.
---@return number ax # The x component of the axis of rotation.
---@return number ay # The y component of the axis of rotation.
---@return number az # The z component of the axis of rotation.
function lovr.headset.getViewPose(view) end
---
---Returns whether a button on a device is pressed.
---
---
---### NOTE:
---When hand tracking is active, pinching will be mapped to the `trigger` button.
---
---@param device lovr.Device # The device.
---@param button lovr.DeviceButton # The button.
---@return boolean down # Whether the button on the device is currently pressed, or `nil` if the device does not have the specified button.
function lovr.headset.isDown(device, button) end
---
---Returns whether LÖVR has VR input focus.
---
---Focus is lost when the VR system menu is shown.
---
---The `lovr.focus` callback can be used to detect when this changes.
---
---@return boolean focused # Whether the application is focused.
function lovr.headset.isFocused() end
---
---Returns whether a button on a device is currently touched.
---
---@param device lovr.Device # The device.
---@param button lovr.DeviceButton # The button.
---@return boolean touched # Whether the button on the device is currently touched, or `nil` if the device does not have the button or it isn't touch-sensitive.
function lovr.headset.isTouched(device, button) end
---
---Returns whether any active headset driver is currently returning pose information for a device.
---
---
---### NOTE:
---If a device is tracked, it is guaranteed to return a valid pose until the next call to `lovr.headset.update`.
---
---@param device? lovr.Device # The device to get the pose of.
---@return boolean tracked # Whether the device is currently tracked.
function lovr.headset.isTracked(device) end
---
---Returns a new Model for the specified device.
---
---
---### NOTE:
---Currently this is only implemented for hand models on the Oculus Quest.
---
---@param device? lovr.Device # The device to load a model for.
---@param options? {animated: boolean} # Options for loading the model.
---@return lovr.Model model # The new Model, or `nil` if a model could not be loaded.
function lovr.headset.newModel(device, options) end
---
---Sets the near and far clipping planes used to render to the headset.
---
---Objects closer than the near clipping plane or further than the far clipping plane will be clipped out of view.
---
---
---### NOTE:
---The default clip distances are 0.01 and 0.0.
---
---@param near number # The distance to the near clipping plane, in meters.
---@param far number # The distance to the far clipping plane, in meters, or 0 for an infinite far clipping plane with a reversed Z range.
function lovr.headset.setClipDistance(near, far) end
---
---Sets the display refresh rate, in Hz.
---
---
---### NOTE:
---Changing the display refresh-rate also changes the frequency of lovr.update() and lovr.draw() as they depend on the display frequency.
---
---@param frequency number # The new refresh rate, in Hz.
---@return boolean success # Whether the display refresh rate was successfully set.
function lovr.headset.setDisplayFrequency(frequency) end
---
---Starts the headset session.
---
---This must be called after the graphics module is initialized, and can only be called once.
---
---Normally it is called automatically by `boot.lua`.
---
function lovr.headset.start() end
---
---Submits the current headset texture to the VR display.
---
---This should be called after calling `lovr.graphics.submit` with the headset render pass.
---
---Normally this is taken care of by `lovr.run`.
---
function lovr.headset.submit() end
---
---Causes the device to vibrate with a custom strength, duration, and frequency, if possible.
---
---@param device? lovr.Device # The device to vibrate.
---@param strength? number # The strength of the vibration (amplitude), between 0 and 1.
---@param duration? number # The duration of the vibration, in seconds.
---@param frequency? number # The frequency of the vibration, in hertz. 0 will use a default frequency.
---@return boolean vibrated # Whether the vibration was successfully triggered by an active headset driver.
function lovr.headset.vibrate(device, strength, duration, frequency) end
---
---Returns whether a button on a device was pressed this frame.
---
---
---### NOTE:
---Some headset backends are not able to return pressed/released information.
---
---These drivers will always return false for `lovr.headset.wasPressed` and `lovr.headset.wasReleased`.
---
---Typically the internal `lovr.headset.update` function will update pressed/released status.
---
---@param device lovr.Device # The device.
---@param button lovr.DeviceButton # The button to check.
---@return boolean pressed # Whether the button on the device was pressed this frame.
function lovr.headset.wasPressed(device, button) end
---
---Returns whether a button on a device was released this frame.
---
---
---### NOTE:
---Some headset backends are not able to return pressed/released information.
---
---These drivers will always return false for `lovr.headset.wasPressed` and `lovr.headset.wasReleased`.
---
---Typically the internal `lovr.headset.update` function will update pressed/released status.
---
---@param device lovr.Device # The device.
---@param button lovr.DeviceButton # The button to check.
---@return boolean released # Whether the button on the device was released this frame.
function lovr.headset.wasReleased(device, button) end
---
---Different types of input devices supported by the `lovr.headset` module.
---
---@alias lovr.Device
---
---The headset.
---
---| "head"
---
---The left controller.
---
---| "hand/left"
---
---The right controller.
---
---| "hand/right"
---
---A shorthand for hand/left.
---
---| "left"
---
---A shorthand for hand/right.
---
---| "right"
---
---A device tracking the left elbow.
---
---| "elbow/left"
---
---A device tracking the right elbow.
---
---| "elbow/right"
---
---A device tracking the left shoulder.
---
---| "shoulder/left"
---
---A device tracking the right shoulder.
---
---| "shoulder/right"
---
---A device tracking the chest.
---
---| "chest"
---
---A device tracking the waist.
---
---| "waist"
---
---A device tracking the left knee.
---
---| "knee/left"
---
---A device tracking the right knee.
---
---| "knee/right"
---
---A device tracking the left foot or ankle.
---
---| "foot/left"
---
---A device tracking the right foot or ankle.
---
---| "foot/right"
---
---A camera device, often used for recording "mixed reality" footage.
---
---| "camera"
---
---A tracked keyboard.
---
---| "keyboard"
---
---The left eye.
---
---| "eye/left"
---
---The right eye.
---
---| "eye/right"
---
---Axes on an input device.
---
---@alias lovr.DeviceAxis
---
---A trigger (1D).
---
---| "trigger"
---
---A thumbstick (2D).
---
---| "thumbstick"
---
---A touchpad (2D).
---
---| "touchpad"
---
---A grip button or grab gesture (1D).
---
---| "grip"
---
---Buttons on an input device.
---
---@alias lovr.DeviceButton
---
---The trigger button.
---
---| "trigger"
---
---The thumbstick.
---
---| "thumbstick"
---
---The touchpad.
---
---| "touchpad"
---
---The grip button.
---
---| "grip"
---
---The menu button.
---
---| "menu"
---
---The A button.
---
---| "a"
---
---The B button.
---
---| "b"
---
---The X button.
---
---| "x"
---
---The Y button.
---
---| "y"
---
---The proximity sensor on a headset.
---
---| "proximity"
---
---These are all of the supported VR APIs that LÖVR can use to power the lovr.headset module.
---
---You can change the order of headset drivers using `lovr.conf` to prefer or exclude specific VR APIs.
---
---At startup, LÖVR searches through the list of drivers in order.
---
---@alias lovr.HeadsetDriver
---
---A VR simulator using keyboard/mouse.
---
---| "desktop"
---
---OpenXR.
---
---| "openxr"
---
---Represents the different types of origins for coordinate spaces.
---
---An origin of "floor" means that the origin is on the floor in the middle of a room-scale play area.
---
---An origin of "head" means that no positional tracking is available, and consequently the origin is always at the position of the headset.
---
---@alias lovr.HeadsetOrigin
---
---The origin is at the head.
---
---| "head"
---
---The origin is on the floor.
---
---| "floor"

View File

@@ -0,0 +1,110 @@
---@meta
---
---The `lovr.system` provides information about the current platform and hardware.
---
---@class lovr.system
lovr.system = {}
---
---Returns the number of logical cores on the system.
---
---@return number cores # The number of logical cores on the system.
function lovr.system.getCoreCount() end
---
---Returns the current operating system.
---
---@return string os # Either "Windows", "macOS", "Linux", "Android" or "Web".
function lovr.system.getOS() end
---
---Returns the window pixel density.
---
---High DPI windows will usually return 2.0 to indicate that there are 2 pixels for every window coordinate in each axis.
---
---On a normal display, 1.0 is returned, indicating that window coordinates match up with pixels 1:1.
---
---@return number density # The pixel density of the window.
function lovr.system.getWindowDensity() end
---
---Returns the dimensions of the desktop window.
---
---
---### NOTE:
---If the window is not open, this will return zeros.
---
---@return number width # The width of the desktop window.
---@return number height # The height of the desktop window.
function lovr.system.getWindowDimensions() end
---
---Returns the height of the desktop window.
---
---
---### NOTE:
---If the window is not open, this will return zero.
---
---@return number width # The height of the desktop window.
function lovr.system.getWindowHeight() end
---
---Returns the width of the desktop window.
---
---
---### NOTE:
---If the window is not open, this will return zero.
---
---@return number width # The width of the desktop window.
function lovr.system.getWindowWidth() end
---
---Returns whether a key on the keyboard is pressed.
---
---@param key lovr.KeyCode # The key.
---@return boolean down # Whether the key is currently pressed.
function lovr.system.isKeyDown(key) end
---
---Returns whether the desktop window is open.
---
---`t.window` can be set to `nil` in `lovr.conf` to disable automatic opening of the window.
---
---In this case, the window can be opened manually using `lovr.system.openWindow`.
---
---@return boolean open # Whether the desktop window is open.
function lovr.system.isWindowOpen() end
---
---Opens the desktop window.
---
---If the window is already open, this function does nothing.
---
---
---### NOTE:
---By default, the window is opened automatically, but this can be disabled by setting `t.window` to `nil` in `conf.lua`.
---
---@param options {width: number, height: number, fullscreen: boolean, resizable: boolean, title: string, icon: string} # Window options.
function lovr.system.openWindow(options) end
---
---Requests permission to use a feature.
---
---Usually this will pop up a dialog box that the user needs to confirm.
---
---Once the permission request has been acknowledged, the `lovr.permission` callback will be called with the result.
---
---Currently, this is only used for requesting microphone access on Android devices.
---
---@param permission lovr.Permission # The permission to request.
function lovr.system.requestPermission(permission) end
---
---These are the different permissions that need to be requested using `lovr.system.requestPermission` on some platforms.
---
---@alias lovr.Permission
---
---Requests microphone access.
---
---| "audiocapture"

View File

@@ -0,0 +1,170 @@
---@meta
---
---The `lovr.thread` module provides functions for creating threads and communicating between them.
---
---These are operating system level threads, which are different from Lua coroutines.
---
---Threads are useful for performing expensive background computation without affecting the framerate or performance of the main thread.
---
---Some examples of this include asset loading, networking and network requests, and physics simulation.
---
---Threads come with some caveats:
---
---- Threads run in a bare Lua environment.
---
---The `lovr` module (and any of lovr's modules) need to
--- be required before they can be used.
--- - To get `require` to work properly, add `require 'lovr.filesystem'` to the thread code.
---- Threads are completely isolated from other threads.
---
---They do not have access to the variables
--- or functions of other threads, and communication between threads must be coordinated through
--- `Channel` objects.
---- The graphics module (or any functions that perform rendering) cannot be used in a thread.
--- Note that this includes creating graphics objects like Models and Textures.
---
---There are "data"
--- equivalent `ModelData` and `Image` objects that can be used in threads though.
---- `lovr.event.pump` cannot be called from a thread.
---- Crashes or problems can happen if two threads access the same object at the same time, so
--- special care must be taken to coordinate access to objects from multiple threads.
---
---@class lovr.thread
lovr.thread = {}
---
---Returns a named Channel for communicating between threads.
---
---@param name string # The name of the Channel to get.
---@return lovr.Channel channel # The Channel with the specified name.
function lovr.thread.getChannel(name) end
---
---Creates a new Thread from Lua code.
---
---
---### NOTE:
---The Thread won\'t start running immediately.
---
---Use `Thread:start` to start it.
---
---The string argument is assumed to be a filename if there isn't a newline in the first 1024 characters.
---
---For really short thread code, an extra newline can be added to trick LÖVR into loading it properly.
---
---@overload fun(filename: string):lovr.Thread
---@overload fun(blob: lovr.Blob):lovr.Thread
---@param code string # The code to run in the Thread.
---@return lovr.Thread thread # The new Thread.
function lovr.thread.newThread(code) end
---
---A Channel is an object used to communicate between `Thread` objects.
---
---Channels are obtained by name using `lovr.thread.getChannel`.
---
---Different threads can send messages on the same Channel to communicate with each other.
---
---Messages can be sent and received on a Channel using `Channel:push` and `Channel:pop`, and are received in a first-in-first-out fashion. The following types of data can be passed through Channels: nil, boolean, number, string, and any LÖVR object.
---
---@class lovr.Channel
local Channel = {}
---
---Removes all pending messages from the Channel.
---
function Channel:clear() end
---
---Returns whether or not the message with the given ID has been read.
---
---Every call to `Channel:push` returns a message ID.
---
---@param id number # The ID of the message to check.
---@return boolean read # Whether the message has been read.
function Channel:hasRead(id) end
---
---Returns a message from the Channel without popping it from the queue.
---
---If the Channel is empty, `nil` is returned.
---
---This can be useful to determine if the Channel is empty.
---
---
---### NOTE:
---The second return value can be used to detect if a `nil` message is in the queue.
---
---@return any message # The message, or `nil` if there is no message.
---@return boolean present # Whether a message was returned (use to detect nil).
function Channel:peek() end
---
---Pops a message from the Channel.
---
---If the Channel is empty, an optional timeout argument can be used to wait for a message, otherwise `nil` is returned.
---
---
---### NOTE:
---Threads can get stuck forever waiting on Channel messages, so be careful.
---
---@param wait? number # How long to wait for a message to be popped, in seconds. `true` can be used to wait forever and `false` can be used to avoid waiting.
---@return any message # The received message, or `nil` if nothing was received.
function Channel:pop(wait) end
---
---Pushes a message onto the Channel.
---
---The following types of data can be pushed: nil, boolean, number, string, and userdata.
---
---Tables should be serialized to strings.
---
---
---### NOTE:
---Threads can get stuck forever waiting on Channel messages, so be careful.
---
---@param message any # The message to push.
---@param wait? number # How long to wait for the message to be popped, in seconds. `true` can be used to wait forever and `false` can be used to avoid waiting.
---@return number id # The ID of the pushed message.
---@return boolean read # Whether the message was read by another thread before the wait timeout.
function Channel:push(message, wait) end
---
---A Thread is an object that runs a chunk of Lua code in the background.
---
---Threads are completely isolated from other threads, meaning they have their own Lua context and can't access the variables and functions of other threads.
---
---Communication between threads is limited and is accomplished by using `Channel` objects.
---
---To get `require` to work properly, add `require 'lovr.filesystem'` to the thread code.
---
---@class lovr.Thread
local Thread = {}
---
---Returns the message for the error that occurred on the Thread, or nil if no error has occurred.
---
---@return string error # The error message, or `nil` if no error has occurred on the Thread.
function Thread:getError() end
---
---Returns whether or not the Thread is currently running.
---
---@return boolean running # Whether or not the Thread is running.
function Thread:isRunning() end
---
---Starts the Thread.
---
---
---### NOTE:
---The arguments can be nil, booleans, numbers, strings, or LÖVR objects.
---
---@param arguments any # Up to 4 arguments to pass to the Thread's function.
function Thread:start(arguments) end
---
---Waits for the Thread to complete, then returns.
---
function Thread:wait() end

View File

@@ -0,0 +1,59 @@
---@meta
---
---The `lovr.timer` module provides a few functions that deal with time.
---
---All times are measured in seconds.
---
---@class lovr.timer
lovr.timer = {}
---
---Returns the average delta over the last second.
---
---@return number delta # The average delta, in seconds.
function lovr.timer.getAverageDelta() end
---
---Returns the time between the last two frames.
---
---This is the same value as the `dt` argument provided to `lovr.update`.
---
---
---### NOTE:
---The return value of this function will remain the same until `lovr.timer.step` is called.
---
---This function should not be used to measure times for game behavior or benchmarking, use `lovr.timer.getTime` for that.
---
---@return number dt # The delta time, in seconds.
function lovr.timer.getDelta() end
---
---Returns the current frames per second, averaged over the last 90 frames.
---
---@return number fps # The current FPS.
function lovr.timer.getFPS() end
---
---Returns the time since some time in the past.
---
---This can be used to measure the difference between two points in time.
---
---@return number time # The current time, in seconds.
function lovr.timer.getTime() end
---
---Sleeps the application for a specified number of seconds.
---
---While the game is asleep, no code will be run, no graphics will be drawn, and the window will be unresponsive.
---
---@param duration number # The number of seconds to sleep for.
function lovr.timer.sleep(duration) end
---
---Steps the timer, returning the new delta time.
---
---This is called automatically in `lovr.run` and it's used to calculate the new `dt` to pass to `lovr.update`.
---
---@return number delta # The amount of time since the last call to this function, in seconds.
function lovr.timer.step() end