Difference between revisions of "love.quit"

(Fixed newin tag to newinoldin, to show it has been renamed/moved.)
m (Function: Better name for return value.)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{newinoldin|[[0.7.0]]|070|[[0.8.0]]|080|type=callback|text=It has been renamed to [[love.event.quit]]}}
+
{{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">
r = love.quit( )
+
abort = love.quit( )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
 
None.
 
None.
 
=== Returns ===
 
=== Returns ===
{{param|boolean|r|Abort quitting. If true, do not close the game.}}
+
{{param|boolean|abort|Abort quitting. If true, do not close the game.}}
 +
 
 
== Example ==
 
== Example ==
 
This example shows how the return value of [[love.quit]] can be used to stop the closing of the game.  
 
This example shows how the return value of [[love.quit]] can be used to stop the closing of the game.  
 
<source lang="lua">
 
<source lang="lua">
local quit = true;
+
local readyToQuit = false
 +
 
 
function love.quit()
 
function love.quit()
    if quit then
+
if not readyToQuit then
        print('We are not ready to quit yet!');
+
print("We are not ready to quit yet!")
        quit = not quit;
+
readyToQuit = true
    else
+
return true
        print('Thanks for playing. Please play again soon!');
+
else
        return quit;
+
print("Thanks for playing. Please play again soon!")
    end
+
return false
    return true;
+
end
 
end
 
end
 
</source>
 
</source>
 +
 
== See Also ==
 
== See Also ==
 
* [[parent::love]]
 
* [[parent::love]]

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