love.event.restart
Available since LÖVE 12.0 |
This function is not supported in earlier versions. |
Restarts the game without relaunching the executable, by adding a quit event with a "restart" parameter to the queue. This cleanly shuts down the main Lua state instance and creates a brand new one.
Equivalent to love.event.push("quit", "restart", restartarg)
.
If LÖVE is programmatically restarted, all active Lua threads must stop their work and the main thread must wait for them to finish, otherwise LOVE may fail to start again. |
Function
Synopsis
love.event.restart( restartarg )
Arguments
Variant restartarg (nil)
- A value which will appear in the love.restart table field after restarting. Can be a table containing multiple Lua values.
Returns
Nothing.
Example
local restartcount = love.restart or 0
function love.keypressed(k)
if k == "r" then
love.event.restart(restartcount + 1)
end
end
function love.draw()
love.graphics.print("Restarted " .. restartcount .. " times.", 8, 8)
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