Skip to content

Commit b37ebce

Browse files
committed
update love-api
1 parent c055822 commit b37ebce

18 files changed

+3382
-343
lines changed

meta/3rd/love2d/library/love.graphics.lua

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ function love.graphics.discard(discardcolor, discardstencil) end
9292
---
9393
---The right and bottom edges of the object are shifted at an angle defined by the shearing factors.
9494
---
95-
---When using the default shader anything drawn with this function will be tinted according to the currently selected color. Set it to pure white to preserve the object's original colors.
95+
---When using the default shader anything drawn with this function will be tinted according to the currently selected color.
96+
---
97+
---Set it to pure white to preserve the object's original colors.
9698
---
9799
---@overload fun(texture: love.Texture, quad: love.Quad, x: number, y: number, r: number, sx: number, sy: number, ox: number, oy: number, kx: number, ky: number)
98100
---@overload fun(drawable: love.Drawable, transform: love.Transform)
@@ -418,7 +420,9 @@ function love.graphics.getTextureTypes() end
418420
function love.graphics.getWidth() end
419421

420422
---
421-
---Sets the scissor to the rectangle created by the intersection of the specified rectangle with the existing scissor. If no scissor is active yet, it behaves like love.graphics.setScissor.
423+
---Sets the scissor to the rectangle created by the intersection of the specified rectangle with the existing scissor.
424+
---
425+
---If no scissor is active yet, it behaves like love.graphics.setScissor.
422426
---
423427
---The scissor limits the drawing area to a specified rectangle. This affects all graphics calls, including love.graphics.clear.
424428
---
@@ -718,7 +722,9 @@ function love.graphics.present() end
718722
---
719723
---Draws text on screen. If no Font is set, one will be created and set (once) if needed.
720724
---
721-
---As of LOVE 0.7.1, when using translation and scaling functions while drawing text, this function assumes the scale occurs first. If you don't script with this in mind, the text won't be in the right position, or possibly even on screen.
725+
---As of LOVE 0.7.1, when using translation and scaling functions while drawing text, this function assumes the scale occurs first.
726+
---
727+
---If you don't script with this in mind, the text won't be in the right position, or possibly even on screen.
722728
---
723729
---love.graphics.print and love.graphics.printf both support UTF-8 encoding. You'll also need a proper Font for special characters.
724730
---

meta/3rd/love2d/library/love.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---@meta
22

33
-- version: 11.4
4+
45
---@class love
56
love = {}
67

meta/3rd/lovr/library/callback.lua

Lines changed: 102 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,47 @@
11
---@meta
22

33
---
4-
---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.
4+
---The `lovr.conf` callback lets you configure default settings for LÖVR.
5+
---
6+
---It is called once right before the game starts.
7+
---
8+
---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.
9+
---
10+
---
11+
---### NOTE:
12+
---Disabling the headset module can improve startup time a lot if you aren't intending to use `lovr.headset`.
13+
---
14+
---You can set `t.window` to nil to avoid creating the window. You can do it yourself later by using `lovr.graphics.createWindow`.
15+
---
16+
---If the `lovr.graphics` module is disabled or the window isn't created, attempting to use any functionality requiring graphics may cause a crash.
17+
---
18+
---Enabling the `t.graphics.debug` flag will add additional error checks and will send messages from the GPU driver to the `lovr.log` callback.
19+
---
20+
---This will decrease performance but can help provide information on performance problems or other bugs.
21+
---
22+
---The `headset.offset` field is a vertical offset applied to the scene for headsets that do not center their tracking origin on the floor.
23+
---
24+
---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.
525
---
626
---@type fun(t: table)
727
lovr.conf = nil
828

929
---
10-
---This callback is called every frame. Use it to render the scene. If a VR headset is connected, anything rendered by this function will appear in the headset display. The display is cleared to the background color before this function is called.
30+
---This callback is called every frame.
31+
---
32+
---Use it to render the scene.
33+
---
34+
---If a VR headset is connected, anything rendered by this function will appear in the headset display.
35+
---
36+
---The display is cleared to the background color before this function is called.
1137
---
1238
---@type fun()
1339
lovr.draw = nil
1440

1541
---
16-
---The "lovr.errhand" callback is run whenever an error occurs. It receives two parameters. The first is a string containing the error message. The second is either nil, or a string containing a traceback (as returned by "debug.traceback()"); if nil, this means "lovr.errhand" is being called in the stack where the error occurred, and it can call "debug.traceback()" itself.
42+
---The "lovr.errhand" callback is run whenever an error occurs.
43+
---
44+
---It receives two parameters. The first is a string containing the error message. The second is either nil, or a string containing a traceback (as returned by "debug.traceback()"); if nil, this means "lovr.errhand" is being called in the stack where the error occurred, and it can call "debug.traceback()" itself.
1745
---
1846
---"lovr.errhand" should return a handler function to run in a loop to show 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 inside "lovr.errhand" or in the handler it returns may not be cleanly reported, so be careful.
1947
---
@@ -23,7 +51,11 @@ lovr.draw = nil
2351
lovr.errhand = nil
2452

2553
---
26-
---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.
54+
---The `lovr.focus` callback is called whenever the application acquires or loses focus (for example, when opening or closing the Steam dashboard).
55+
---
56+
---The callback receives a single argument, focused, which is a boolean indicating whether or not the application is now focused.
57+
---
58+
---It may make sense to pause the game or reduce visual fidelity when the application loses focus.
2759
---
2860
---@type fun(focused: boolean)
2961
lovr.focus = nil
@@ -41,35 +73,67 @@ lovr.keypressed = nil
4173
lovr.keyreleased = nil
4274

4375
---
44-
---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.
76+
---This callback is called once when the app starts.
77+
---
78+
---It should be used to perform initial setup work, like loading resources and initializing classes and variables.
79+
---
80+
---
81+
---### NOTE:
82+
---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 `args` table.
83+
---
84+
---The `args` table follows the [Lua standard](https://en.wikibooks.org/wiki/Lua_Programming/command_line_parameter).
85+
---
86+
---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.
87+
---
88+
---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.
4589
---
4690
---@type fun(args: table)
4791
lovr.load = nil
4892

4993
---
50-
---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.
94+
---This callback is called when a message is logged.
95+
---
96+
---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.
5197
---
5298
---The message can have a "tag" that is a short string representing the sender, and a "level" indicating how severe the message is.
5399
---
54-
---The `t.graphics.debug` flag in `lovr.conf` can be used to get log messages from the GPU driver (tagged as `GL`). It is also possible to emit your own log messages using `lovr.event.push`.
100+
---The `t.graphics.debug` flag in `lovr.conf` can be used to get log messages from the GPU driver (tagged as `GL`).
101+
---
102+
---It is also possible to emit your own log messages using `lovr.event.push`.
55103
---
56104
---@type fun(message: string, level: string, tag: string)
57105
lovr.log = nil
58106

59107
---
60-
---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, you could render a single eye instead of a stereo view, apply postprocessing effects, add 2D UI, or render the scene from an entirely different viewpoint for a third person camera.
108+
---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.
109+
---
110+
---It can be overridden for custom mirroring behavior.
111+
---
112+
---For example, you could render a single eye instead of a stereo view, apply postprocessing effects, add 2D UI, or render the scene from an entirely different viewpoint for a third person camera.
113+
---
114+
---
115+
---### NOTE:
116+
---When this callback is called, the camera is located at `(0, 0, 0)` and is looking down the negative-z axis.
117+
---
118+
---Note that the usual graphics state applies while `lovr.mirror` is invoked, so you may need to reset graphics state at the end of `lovr.draw` to get the result you want.
61119
---
62120
---@type fun()
63121
lovr.mirror = nil
64122

65123
---
66-
---This callback contains a permission response previously requested with `lovr.system.requestPermission`. The callback contains information on whether permission was granted or denied.
124+
---This callback contains a permission response previously requested with `lovr.system.requestPermission`.
125+
---
126+
---The callback contains information on whether permission was granted or denied.
67127
---
68128
---@type fun(permission: lovr.Permission, granted: boolean)
69129
lovr.permission = nil
70130

71131
---
72-
---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.
132+
---This callback is called right before the application is about to quit.
133+
---
134+
---Use it to perform any necessary cleanup work.
135+
---
136+
---A truthy value can be returned from this callback to abort quitting.
73137
---
74138
---@type fun():boolean
75139
lovr.quit = nil
@@ -81,13 +145,23 @@ lovr.quit = nil
81145
lovr.resize = nil
82146

83147
---
84-
---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.
148+
---This callback is called when a restart from `lovr.event.restart` is happening.
149+
---
150+
---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`.
151+
---
152+
---Object instances can not be used as the restart value, since they are destroyed as part of the cleanup process.
153+
---
154+
---
155+
---### NOTE:
156+
---Only nil, booleans, numbers, and strings are supported types for the return value.
85157
---
86158
---@type fun():any
87159
lovr.restart = nil
88160

89161
---
90-
---This callback is the main entry point for a LÖVR program. It is responsible for calling `lovr.load` and returning the main loop function.
162+
---This callback is the main entry point for a LÖVR program.
163+
---
164+
---It is responsible for calling `lovr.load` and returning the main loop function.
91165
---
92166
---@type fun():function
93167
lovr.run = nil
@@ -97,19 +171,33 @@ lovr.run = nil
97171
---
98172
---For example, when `shift + 1` is pressed on an American keyboard, `lovr.textinput` will be called with `!`.
99173
---
174+
---
175+
---### NOTE:
176+
---Some characters in UTF-8 unicode take multiple bytes to encode.
177+
---
178+
---Due to the way Lua works, the length of these strings will be bigger than 1 even though they are just a single character. `lovr.graphics.print` is compatible with UTF-8 but doing other string processing on these strings may require a library.
179+
---
180+
---Lua 5.3+ has support for working with UTF-8 strings.
181+
---
100182
---@type fun(text: string, code: number)
101183
lovr.textinput = nil
102184

103185
---
104-
---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.
186+
---The `lovr.threaderror` callback is called whenever an error occurs in a Thread.
187+
---
188+
---It receives the Thread object where the error occurred and an error message.
105189
---
106190
---The default implementation of this callback will call `lovr.errhand` with the error.
107191
---
108192
---@type fun(thread: lovr.Thread, message: string)
109193
lovr.threaderror = nil
110194

111195
---
112-
---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.
196+
---The `lovr.update` callback should be used to update your game's logic.
197+
---
198+
---It receives a single parameter, `dt`, which represents the amount of elapsed time between frames.
199+
---
200+
---You can use this value to scale timers, physics, and animations in your game so they play at a smooth, consistent speed.
113201
---
114202
---@type fun(dt: number)
115203
lovr.update = nil

0 commit comments

Comments
 (0)