Difference between revisions of "love.quit"
m (→Function: Better name for return value.) |
|||
(12 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
− | {{newin|[[0.7.0]]}} | + | {{newin|[[0.7.0]]|070|type=callback}} |
− | |||
Callback function triggered when the game is closed. | Callback function triggered when the game is closed. | ||
== Function == | == Function == | ||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
− | + | abort = love.quit( ) | |
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
None. | None. | ||
=== Returns === | === Returns === | ||
− | {{param|boolean| | + | {{param|boolean|abort|Abort quitting. If true, do not close the game.}} |
+ | |||
+ | == Example == | ||
+ | This example shows how the return value of [[love.quit]] can be used to stop the closing of the game. | ||
+ | <source lang="lua"> | ||
+ | local readyToQuit = false | ||
+ | |||
+ | function love.quit() | ||
+ | if not readyToQuit then | ||
+ | print("We are not ready to quit yet!") | ||
+ | readyToQuit = true | ||
+ | return true | ||
+ | else | ||
+ | print("Thanks for playing. Please play again soon!") | ||
+ | return false | ||
+ | end | ||
+ | end | ||
+ | </source> | ||
+ | |||
== See Also == | == See Also == | ||
* [[parent::love]] | * [[parent::love]] | ||
+ | * [[love.event.quit]] | ||
[[Category:Callbacks]] | [[Category:Callbacks]] | ||
{{#set:Description=Callback function triggered when the game is closed.}} | {{#set:Description=Callback function triggered when the game is closed.}} | ||
+ | {{#set:Subcategory=General}} | ||
== Other Languages == | == Other Languages == | ||
{{i18n|love.quit}} | {{i18n|love.quit}} |
Latest revision as of 14:37, 5 October 2021
Available since LÖVE 0.7.0 |
This callback is not supported in earlier versions. |
Callback function triggered when the game is closed.
Function
Synopsis
abort = love.quit( )
Arguments
None.
Returns
boolean abort
- Abort quitting. If true, do not close the game.
Example
This example shows how the return value of love.quit can be used to stop the closing of the game.
local readyToQuit = false
function love.quit()
if not readyToQuit then
print("We are not ready to quit yet!")
readyToQuit = true
return true
else
print("Thanks for playing. Please play again soon!")
return false
end
end
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info